Net::OpenDHT.3pm

Langue: en

Version: 2006-05-01 (mandriva - 01/05/08)

Section: 3 (Bibliothèques de fonctions)

NAME

Net::OpenDHT - Access the Open Distributed Hash Table (Open DHT)

SYNOPSIS

   my $dht = Net::OpenDHT->new();
   $dht->application("My Application");
   $dht->server($server); # see below
 
 
   $dht->put($key, $value, $ttl);
   my $value  = $dht->fetch($key);
   my @values = $dht->fetch($key);
 
 

DESCRIPTION

The Net::OpenDHT module provides a simple interface to the Open DHT service. Open DHT is a publicly accessible distributed hash table (DHT) service. In contrast to the usual DHT model, clients of Open DHT do not need to run a DHT node in order to use the service. Instead, they can issue put and get operations to any DHT node, which processes the operations on their behalf. No credentials or accounts are required to use the service, and the available storage is fairly shared across all active clients.

This service model of DHT usage greatly simplifies deploying client applications. By using Open DHT as a highly-available naming and storage service, clients can ignore the complexities of deploying and maintaining a DHT and instead concentrate on developing more sophisticated distributed applications.

What this essentially gives you as a Perl author is robust storage for a small amount of data. This can be used as a distributed cache or data store.

Read the following for full semantics about the Open DHT:

   http://opendht.org/users-guide.html
 
 

METHODS


new

The constructor:

   my $dht = Net::OpenDHT->new();
 
 

application

The application method sets the name of the application. You should set this as a courtesy to the Open DHT developers:

   $dht->application("My Application");
 
 

fetch

The get method fetches data from the Open DHT. Note that multiple values can be set for a key:

   my $value  = $dht->fetch($key);
   my @values = $dht->fetch($key);
 
 

put

The put method puts data into the Open DHT. The key has a maximum length of 20 bytes, the value a maximum length of 1024 bytes. You must also pass in a time to live in seconds:

   $dht->put($key, $value, $ttl);
 
 

server

The module automatically finds a topologically-close gateway to the DHT via the CoralCDN OASIS service. You may override this and provide your own gateway with this method:

   $dht->server($server);
 
 

AUTHOR

Leon Brocard <acme@astray.com>. Copyright (C) 2005-6, Leon Brocard

This module is free software; you can redistribute it or modify it under the same terms as Perl itself.