Show / Hide Table of Contents

Class FileStore<TName, TValue>

A file based repository for name value pairs.

Inheritance
Object
FileStore<TName, TValue>
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Ipfs.Engine
Assembly: Ipfs.Engine.dll
Syntax
public class FileStore<TName, TValue>
    where TValue : class
Type Parameters
Name Description
TName

The type used for a unique name.

TValue

The type used for the value.

Remarks

All operations are atomic, a reader/writer lock is used.

Fields

| Improve this Doc View Source

JsonDeserialize

A function to read the JSON encoded entity from the stream.

Declaration
public static Func<Stream, TName, CancellationToken, Task<TValue>> JsonDeserialize
Field Value
Type Description
Func<Stream, TName, CancellationToken, Task<TValue>>
Remarks

This is the default Deserialize.

| Improve this Doc View Source

JsonSerialize

A function to write the JSON encoded entity to the stream.

Declaration
public static Func<Stream, TName, TValue, CancellationToken, Task> JsonSerialize
Field Value
Type Description
Func<Stream, TName, TValue, CancellationToken, Task>
Remarks

This is the default Serialize.

Properties

| Improve this Doc View Source

Deserialize

Retrieves the value from the stream.

Declaration
public Func<Stream, TName, CancellationToken, Task<TValue>> Deserialize { get; set; }
Property Value
Type Description
Func<Stream, TName, CancellationToken, Task<TValue>>

Defaults to using JsonDeserialize

| Improve this Doc View Source

Folder

The fully qualififed path to a directory that stores the name value pairs.

Declaration
public string Folder { get; set; }
Property Value
Type Description
String

A fully qualified path.

Remarks

The directory must already exist.

| Improve this Doc View Source

KeyToName

A function that converts the case insensitive key to a name.

Declaration
public Func<string, TName> KeyToName { get; set; }
Property Value
Type Description
Func<String, TName>
| Improve this Doc View Source

Names

Gets the names in the file store.

Declaration
public IEnumerable<TName> Names { get; }
Property Value
Type Description
IEnumerable<TName>

A sequence of TName.

| Improve this Doc View Source

NameToKey

A function that converts the name to a case insensitive key name.

Declaration
public Func<TName, string> NameToKey { get; set; }
Property Value
Type Description
Func<TName, String>
| Improve this Doc View Source

Serialize

Sends the value to the stream.

Declaration
public Func<Stream, TName, TValue, CancellationToken, Task> Serialize { get; set; }
Property Value
Type Description
Func<Stream, TName, TValue, CancellationToken, Task>

Defaults to using JsonSerialize.

| Improve this Doc View Source

Values

Gets the values in the file store.

Declaration
public IEnumerable<TValue> Values { get; }
Property Value
Type Description
IEnumerable<TValue>

A sequence of TValue.

Methods

| Improve this Doc View Source

ExistsAsync(TName, CancellationToken)

Determines if the name exists.

Declaration
public Task<bool> ExistsAsync(TName name, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
TName name

The unique name of the entity.

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

Returns
Type Description
Task<Boolean>

A task that represents the asynchronous operation. The task's result is true if the name exists.

| Improve this Doc View Source

GetAsync(TName, CancellationToken)

Get the value with the specified name.

Declaration
public Task<TValue> GetAsync(TName name, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
TName name

The unique name of the entity.

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

Returns
Type Description
Task<TValue>

A task that represents the asynchronous operation. The task's result is a TValue

Exceptions
Type Condition
KeyNotFoundException

When the name does not exist.

| Improve this Doc View Source

GetPath(TName)

Local file system path to the name.

Declaration
public string GetPath(TName name)
Parameters
Type Name Description
TName name
Returns
Type Description
String
| Improve this Doc View Source

LengthAsync(TName, CancellationToken)

Get's the serialised length of the entity.

Declaration
public Task<long? > LengthAsync(TName name, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
TName name

The unique name of the entity.

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

Returns
Type Description
Task<Nullable<Int64>>

A task that represents the asynchronous operation. The task's result is a nullable long.

Remarks

Return a null when the name does not exist.

| Improve this Doc View Source

PutAsync(TName, TValue, CancellationToken)

Put the value with the specified name.

Declaration
public Task PutAsync(TName name, TValue value, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
TName name

The unique name of the entity.

TValue value

The entity.

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

Returns
Type Description
Task

A task that represents the asynchronous operation.

Remarks

If name already exists, it's value is overwriten.

The file is deleted if an exception is encountered.

| Improve this Doc View Source

RemoveAsync(TName, CancellationToken)

Remove the value with the specified name.

Declaration
public Task RemoveAsync(TName name, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
TName name

The unique name of the entity.

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

Returns
Type Description
Task

A task that represents the asynchronous operation.

Remarks

A non-existent name does nothing.

| Improve this Doc View Source

TryGetAsync(TName, CancellationToken)

Try to get the value with the specified name.

Declaration
public Task<TValue> TryGetAsync(TName name, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
TName name

The unique name of the entity.

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

Returns
Type Description
Task<TValue>

A task that represents the asynchronous operation. The task's result is a TValue or null if the name does not exist.

  • Improve this Doc
  • View Source
Back to top Generated by DocFX