Class FileKeyValueStore
An IKeyValueStore implementation that uses text files for storage.
Inherited Members
Namespace: Unity.Cloud.Common
Syntax
public class FileKeyValueStore : IKeyValueStore
Constructors
FileKeyValueStore(String, IStringObfuscator)
Creates a FileKeyValueStore instance.
Declaration
public FileKeyValueStore(string cacheFilePath, IStringObfuscator stringObfuscator = null)
Parameters
Type | Name | Description |
---|---|---|
String | cacheFilePath | The platform-specific base path for all stored data. |
IStringObfuscator | stringObfuscator | The optional IStringObfuscator implementation. |
Methods
DeleteCacheAsync(String)
A Task that deletes a unique filename in the current IKeyValueStore.
Declaration
public async Task DeleteCacheAsync(string filename)
Parameters
Type | Name | Description |
---|---|---|
String | filename | The unique filename to delete from the current IKeyValueStore. |
Returns
Type | Description |
---|---|
Task | A Task that deletes a unique filename in the current IKeyValueStore. |
Implements
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the filename is null or empty. |
ReadCacheAsync(String)
A Task that reads a cached string from the current IKeyValueStore.
Declaration
public async Task<string> ReadCacheAsync(string filename)
Parameters
Type | Name | Description |
---|---|---|
String | filename | The unique filename to look for in the current IKeyValueStore. |
Returns
Type | Description |
---|---|
Task<String> | A Task that results in the cached string value. |
Implements
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the filename is null or empty. |
FileNotFoundException | Thrown if the filename does not exist. |
ValidateFilenameExistsAsync(String)
A Task that validates if a filename exists in the IKeyValueStore.
Declaration
public Task<bool> ValidateFilenameExistsAsync(string filename)
Parameters
Type | Name | Description |
---|---|---|
String | filename | The unique filename to look for in the current IKeyValueStore. |
Returns
Type | Description |
---|---|
Task<Boolean> | A task that has a result of true if the filename is found, false otherwise. |
Implements
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the filename is null or empty. |
WriteToCacheAsync(String, String)
A Task that writes a string content value under a unique filename in the current IKeyValueStore.
Declaration
public async Task WriteToCacheAsync(string filename, string content)
Parameters
Type | Name | Description |
---|---|---|
String | filename | The unique filename that will hold the content value in the current IKeyValueStore. |
String | content | The string content to write. |
Returns
Type | Description |
---|---|
Task | A Task that writes a string content value under a unique filename in the current IKeyValueStore. |
Implements
Remarks
Overwrite any previous value.
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the filename is null or empty. |