Algorithm-Kademlia
view release on metacpan or search on metacpan
CODE_OF_CONDUCT.md view on Meta::CPAN
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
https://github.com/sanko/Algorithm-Kademlia/discussions.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series
of actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.
### 3. Temporary Ban
```perl
my $storage = Algorithm::Kademlia::Storage->new( ttl => 3600 );
```
## `put( $key_bin, $value_bin, [ $publisher_id_bin ] )`
Stores a value.
```
$storage->put($cid_bin, $data_bin, $provider_id);
```
## `get( $key_bin )`
Retrieves a value. Returns `undef` if the key is missing or has expired.
```perl
my $data = $storage->get($cid_bin);
die 'Expired or not found' unless defined $data;
```
## `entries( )`
Returns a hash reference of all non-expired entries in the store.
```perl
my %all = $storage->entries();
for my ($key, $info) (%all) {
lib/Algorithm/Kademlia.pod view on Meta::CPAN
=head2 C<new( [ ttl =E<gt> 86400 ] )>
Constructor. C<ttl> is the time-to-live for entries in seconds.
my $storage = Algorithm::Kademlia::Storage->new( ttl => 3600 );
=head2 C<put( $key_bin, $value_bin, [ $publisher_id_bin ] )>
Stores a value.
$storage->put($cid_bin, $data_bin, $provider_id);
=head2 C<get( $key_bin )>
Retrieves a value. Returns C<undef> if the key is missing or has expired.
my $data = $storage->get($cid_bin);
die 'Expired or not found' unless defined $data;
=head2 C<entries( )>
Returns a hash reference of all non-expired entries in the store.
my %all = $storage->entries();
for my ($key, $info) (%all) {
say 'Key: ' . unpack('H*', $key) . ' Value: ' . $info->{value};
}
( run in 2.365 seconds using v1.01-cache-2.11-cpan-e1769b4cff6 )