Brunet DHT API
From BoykinWiki
This is deprecated, please see this
Brunet DHT [1] implementation presents the following API:
Create(key k, value v, time-to-live ttl): Insert a key-value pair (k, v) into the hashtable for ttl seconds, only if the key k does not already exists. Returns true on success, otherwise returns an error. Note that the entry is stored only for ttl seconds.
Put(key k, value v, time-to-live ttl): Same as Create except that it allows the values to be put under the existing key
Get(key k): Returns all live values (time-to-live not expired) associated with key k.
In C#
The C# method signature of the above API looks like the following:
bool Create(string key, string value, int ttl);
bool Put(string key, string value, int ttl);
DhtGetResult[] Get(string key);
Note:
- Create() throws an exception when the key already exists
- Get() returns an array of DhtGetResult, which is merely a simple class with the fields <age, ttl, value> and can be mapped to a struct or dictionary in different programming languages
- age: the time in seconds that this entry has already spent in DHT
- ttl: the time-to-live left. ttl + age == original ttl
- value: the value of the entry
