Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JSONDiskStorage ¶
type JSONDiskStorage struct {
// contains filtered or unexported fields
}
JSONDiskStorage is a Storage implementation that uses the file system as persistence backend, storing the objects as JSON. This requires that any object that has to be stored is Marshallable and Unmarshallable.
func NewJSONDiskStorage ¶
func NewJSONDiskStorage(rootPath string) JSONDiskStorage
NewJSONDiskStorage returns a JSONDiskStorage using the rootPath argument as root folder for the persistent entities.
func (JSONDiskStorage) Delete ¶
func (j JSONDiskStorage) Delete(key string) error
Delete removes the cached data for the given key. If the data does not exist, the system does not return any error.
func (JSONDiskStorage) Read ¶
func (j JSONDiskStorage) Read(key string, valuePtr interface{}) (int64, error)
Read gets the value associated to a given key and stores it in the value referenced by the pointer passed as second argument This implementation adds a restriction to the key name: it must be a valid file name (without extension).
func (JSONDiskStorage) Write ¶
func (j JSONDiskStorage) Write(key string, value interface{}) error
Write stores a value for a given key. Implementors must save also the time when it was stored. This implementation adds a restriction to the key name: it must be a valid file name (without extension).
type Storage ¶
type Storage interface { // Write stores a value for a given key. Implementors must save also the time when it was stored. // The value can be any type. Write(key string, value interface{}) error // Read gets the value associated to a given key and stores in the value referenced by the pointer passed as argument. // It returns the Unix timestamp when the value was stored (in seconds), or an error if the Read operation failed. // It may return any type of value. Read(key string, valuePtr interface{}) (int64, error) // Delete removes the cached data for the given key. If the data does not exist, the system does not return // any error. Delete(key string) error }
Storage defines the interface of a Key-Value storage system, which is able to store the timestamp where the key was stored.