Documentation ¶
Index ¶
Constants ¶
View Source
const ( // DefaultTTL specifies the "Time To Live" of the disk storage. DefaultTTL = 1 * time.Minute )
Variables ¶
View Source
var ErrNotFound = errors.New("key not found")
ErrNotFound defines an error that will be returned when trying to access a storage entry that can't be found
Functions ¶
func DefaultPath ¶
DefaultPath returns a default folder/filename dir to a Storer for an integration from the given name. The name of the file will be the name of the integration with the .json extension.
Types ¶
type StorePath ¶
type StorePath interface { GetFilePath() string CleanOldFiles() }
StorePath will handle the location for the persistence.
type Storer ¶
type Storer interface { // Set associates a value with a given key. Implementors must save also the time when it has been stored and return it. // The value can be any type. Set(key string, value interface{}) int64 // Get 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 Get operation failed. // It may return any type of value. Get(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 // Save persists all the data in the storer. Save() error }
Storer defines the interface of a Key-Value storage system, which is able to store the timestamp where the key was stored.
func NewFileStore ¶
NewFileStore returns a disk-backed Storer using the provided file dir
func NewInMemoryStore ¶
func NewInMemoryStore() Storer
NewInMemoryStore will create and initialize an in-memory Storer (not persistent).
Click to show internal directories.
Click to hide internal directories.