C# Класс Kademlia.LocalStorage

Stores key/value pairs assigned to our node. Automatically handles persistence to disk.
Показать файл Открыть проект

Открытые методы

Метод Описание
Contains ( ID key, ID hash ) : bool

Do we have the specified value for the given key?

ContainsKey ( ID key ) : bool

Do we have any data for the given key?

ContainsTag ( ID tag_id ) : bool
ContainsUrl ( ID tag_id, Uri uri ) : bool
Expire ( ) : void

Expire old entries

Get ( ID key ) : IList

Get all data values for the given key, or an empty list.

Get ( ID key, ID hash ) : string

Get a particular value by key and hash, or null.

GetAllElements ( ) : IList
GetHashes ( ID key ) : IList

Gets a list of all value hashes for the given key It's a copy, iterate all you want.

GetKeys ( ) : IList

Get all IDs, so we can go through and republish everything. It's a copy so you can iterate it all you want.

GetPublicationTime ( ID tag_id, Uri uri ) : DateTime
GetPublicationTime ( ID key, ID hash ) : DateTime?

Returns when the given value was last inserted by its original publisher, or null if the value isn't present.

LocalStorage ( ) : System

Make a new LocalStorage. Uses the executing assembly's name to determine the filename for on-disk storage. If another LocalStorage on the machine is already using that file, we use a temp directory.

Put ( ID key, ID hash, string val, DateTime timestamp, TimeSpan keepFor ) : void

Store a key/value pair published originally at the given UTC timestamp. Value is kept until keepTime past timestamp.

Put ( ID tag_id, Uri uri, DateTime publicationTime ) : void
RefreshResource ( ID tag_id, Uri uri, DateTime timestamp ) : void
Restamp ( ID key, ID hash, DateTime newStamp, TimeSpan newKeep ) : void

Change the timing information on an existing entry, if extant.

SearchFor ( string query ) : KademliaResource[]
StoreResource ( CompleteTag tag, Uri uri, DateTime publicationTime ) : void

Приватные методы

Метод Описание
BackgroundSave ( ) : void

Save the store in the background. PRECONSITION: We have the mutex and diskFilename is set.

CreatePath ( string path ) : void

Create all folders in a path, if missing.

PathFor ( ID key, ID hash ) : string

Where should we save a particular value?

SaveIndex ( ) : void

Save the index now.

Описание методов

Contains() публичный Метод

Do we have the specified value for the given key?
public Contains ( ID key, ID hash ) : bool
key ID
hash ID
Результат bool

ContainsKey() публичный Метод

Do we have any data for the given key?
public ContainsKey ( ID key ) : bool
key ID
Результат bool

ContainsTag() публичный Метод

public ContainsTag ( ID tag_id ) : bool
tag_id ID
Результат bool

ContainsUrl() публичный Метод

public ContainsUrl ( ID tag_id, Uri uri ) : bool
tag_id ID
uri Uri
Результат bool

Expire() публичный Метод

Expire old entries
public Expire ( ) : void
Результат void

Get() публичный Метод

Get all data values for the given key, or an empty list.
public Get ( ID key ) : IList
key ID
Результат IList

Get() публичный Метод

Get a particular value by key and hash, or null.
public Get ( ID key, ID hash ) : string
key ID
hash ID
Результат string

GetAllElements() публичный Метод

public GetAllElements ( ) : IList
Результат IList

GetHashes() публичный Метод

Gets a list of all value hashes for the given key It's a copy, iterate all you want.
public GetHashes ( ID key ) : IList
key ID
Результат IList

GetKeys() публичный Метод

Get all IDs, so we can go through and republish everything. It's a copy so you can iterate it all you want.
public GetKeys ( ) : IList
Результат IList

GetPublicationTime() публичный Метод

public GetPublicationTime ( ID tag_id, Uri uri ) : DateTime
tag_id ID
uri Uri
Результат DateTime

GetPublicationTime() публичный Метод

Returns when the given value was last inserted by its original publisher, or null if the value isn't present.
public GetPublicationTime ( ID key, ID hash ) : DateTime?
key ID
hash ID
Результат DateTime?

LocalStorage() публичный Метод

Make a new LocalStorage. Uses the executing assembly's name to determine the filename for on-disk storage. If another LocalStorage on the machine is already using that file, we use a temp directory.
public LocalStorage ( ) : System
Результат System

Put() публичный Метод

Store a key/value pair published originally at the given UTC timestamp. Value is kept until keepTime past timestamp.
public Put ( ID key, ID hash, string val, DateTime timestamp, TimeSpan keepFor ) : void
key ID
hash ID The hash of the value
val string
timestamp DateTime
keepFor TimeSpan
Результат void

Put() публичный Метод

public Put ( ID tag_id, Uri uri, DateTime publicationTime ) : void
tag_id ID
uri Uri
publicationTime DateTime
Результат void

RefreshResource() публичный Метод

public RefreshResource ( ID tag_id, Uri uri, DateTime timestamp ) : void
tag_id ID
uri Uri
timestamp DateTime
Результат void

Restamp() публичный Метод

Change the timing information on an existing entry, if extant.
public Restamp ( ID key, ID hash, DateTime newStamp, TimeSpan newKeep ) : void
key ID
hash ID
newStamp DateTime
newKeep TimeSpan
Результат void

SearchFor() публичный Метод

public SearchFor ( string query ) : KademliaResource[]
query string
Результат KademliaResource[]

StoreResource() публичный Метод

public StoreResource ( CompleteTag tag, Uri uri, DateTime publicationTime ) : void
tag CompleteTag
uri Uri
publicationTime DateTime
Результат void