Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterTypeForStorage ¶
func RegisterTypeForStorage(val interface{})
RegisterTypeForStorage registers a custom type (e.g. a struct) for use in the key value store. This is necessary if you intend to pass custom structs to Store.Set() rather than primitive types.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store provides an in-memory key/value store which is persisted to a file. The file handle itself is not kept locked for the duration; it is only locked during load and save, to make it concurrency friendly. When saving, the store uses optimistic locking to determine whether the db on disk has been modified by another process; in which case it loads the latest version and re-applies modifications made during this session. This means the Lost Update db concurrency issue is possible; so don't use this if you need more DB integrity than Read Committed isolation levels.
func NewStore ¶
NewStore creates a new key/value store and initialises it with contents from the named file, if it exists
func (*Store) Remove ¶
Remove removes the key and its value from the store in memory Changes are not persisted until you call Save()
func (*Store) RemoveAll ¶
func (k *Store) RemoveAll()
RemoveAll removes all entries from the store These changes are not persisted until you call Save()
func (*Store) Save ¶
Save persists the changes made to disk If any changes have been written by other code they will be merged