Documentation
¶
Overview ¶
Package keystore is a simple key-value storage system with file and memory backing
Index ¶
- Variables
- type FileBackedMemStore
- func (fs *FileBackedMemStore) Clear(keys ...string)
- func (fs *FileBackedMemStore) Get(key string, r io.ReaderFrom) error
- func (fs *FileBackedMemStore) Remove(key string) error
- func (fs *FileBackedMemStore) Rename(oldkey, newkey string) error
- func (fs *FileBackedMemStore) Set(key string, w io.WriterTo) error
- type FileStore
- func (fs *FileStore) Exists(key string) bool
- func (fs *FileStore) Get(key string, r io.ReaderFrom) error
- func (fs *FileStore) Keys() []string
- func (fs *FileStore) Remove(key string) error
- func (fs *FileStore) Rename(oldkey, newkey string) error
- func (fs *FileStore) Set(key string, w io.WriterTo) error
- func (fs *FileStore) Stat(key string) (os.FileInfo, error)
- type Float32
- type Float64
- type Int
- type Int16
- type Int32
- type Int64
- type Int8
- type Mangler
- type MemStore
- func (ms *MemStore) Exists(key string) bool
- func (ms *MemStore) Get(key string, r io.ReaderFrom) error
- func (ms *MemStore) GetAll(data map[string]io.ReaderFrom) error
- func (ms *MemStore) Keys() []string
- func (ms *MemStore) ReadFrom(r io.Reader) (int64, error)
- func (ms *MemStore) Remove(key string) error
- func (ms *MemStore) RemoveAll(keys ...string)
- func (ms *MemStore) Rename(oldkey, newkey string) error
- func (ms *MemStore) Set(key string, w io.WriterTo) error
- func (ms *MemStore) SetAll(data map[string]io.WriterTo) error
- func (ms *MemStore) WriteTo(w io.Writer) (int64, error)
- type Store
- type String
- type Uint
- type Uint16
- type Uint32
- type Uint64
- type Uint8
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnknownKey = errors.New("key not found") ErrKeyExists = errors.New("key already exists") ErrInvalidKey = errors.New("key contains invalid characters") )
Errors
Functions ¶
This section is empty.
Types ¶
type FileBackedMemStore ¶
type FileBackedMemStore struct { FileStore // contains filtered or unexported fields }
FileBackedMemStore combines both a FileStore and a MemStore
func NewFileBackedMemStore ¶
func NewFileBackedMemStore(baseDir, tmpDir string, mangler Mangler) (*FileBackedMemStore, error)
NewFileBackedMemStore create a new Store which uses the filesystem for permanent storage, but uses memory for caching
func NewFileBackedMemStoreFromFileStore ¶
func NewFileBackedMemStoreFromFileStore(filestore *FileStore) *FileBackedMemStore
NewFileBackedMemStoreFromFileStore uses an existing FileStore to create a new File Backed Memory Store
func (*FileBackedMemStore) Clear ¶
func (fs *FileBackedMemStore) Clear(keys ...string)
Clear removes keys from the memory cache. Specifying no keys removes all data
func (*FileBackedMemStore) Get ¶
func (fs *FileBackedMemStore) Get(key string, r io.ReaderFrom) error
Get retrieves a key from the Store, first looking in the memcache and then going to the filesystem
func (*FileBackedMemStore) Remove ¶
func (fs *FileBackedMemStore) Remove(key string) error
Remove deletes a key from both the memcache and the filesystem
func (*FileBackedMemStore) Rename ¶
func (fs *FileBackedMemStore) Rename(oldkey, newkey string) error
Rename moves data from an existing key to a new, unused key
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
FileStore implements the Store interface and provides a file backed keystore
func NewFileStore ¶
NewFileStore creates a file backed key-value store
func (*FileStore) Get ¶
func (fs *FileStore) Get(key string, r io.ReaderFrom) error
Get retrieves the key data from the filesystem
type Float32 ¶
type Float32 float32
Float32 is a float32 that implements io.ReaderFrom and io.WriterTo
type Float64 ¶
type Float64 float64
Float64 is a float64 that implements io.ReaderFrom and io.WriterTo
type Int ¶
type Int int
Int is a int that implements io.ReaderFrom and io.WriterTo
type Int16 ¶
type Int16 int16
Int16 is a int16 that implements io.ReaderFrom and io.WriterTo
type Int32 ¶
type Int32 int32
Int32 is a int32 that implements io.ReaderFrom and io.WriterTo
type Int64 ¶
type Int64 int64
Int64 is a int64 that implements io.ReaderFrom and io.WriterTo
type Int8 ¶
type Int8 int8
Int8 is a int8 that implements io.ReaderFrom and io.WriterTo
type Mangler ¶
Mangler is an interface for the methods required to un/mangle a key
var Base64Mangler Mangler = base64Mangler{}
Base64Mangler represents the default Mangler that simple base64 encodes the key
var NoMangle Mangler = noMangle{}
NoMangle is a mangler that performs no mangling. This should only be used when you are certain that there are no filesystem special characters in the key name
type MemStore ¶
type MemStore struct {
// contains filtered or unexported fields
}
MemStore implements Store and does so entirely in memory
func NewMemStore ¶
func NewMemStore() *MemStore
NewMemStore creates a new memory-backed key-value store
func (*MemStore) Get ¶
func (ms *MemStore) Get(key string, r io.ReaderFrom) error
Get retrieves the key data from memory
func (*MemStore) GetAll ¶
func (ms *MemStore) GetAll(data map[string]io.ReaderFrom) error
GetAll retrieves data for all of the keys given. Useful to reduce locking. Unknown Key errors are not returned, only errors from the ReaderFrom's
func (*MemStore) ReadFrom ¶
ReadFrom implements the io.ReaderFrom interface allowing a MemStore to be be retrieved in another Store
func (*MemStore) RemoveAll ¶
RemoveAll will attempt to remove all keys given. It does not return an error if a key doesn't exist
type Store ¶
type Store interface { Get(string, io.ReaderFrom) error Set(string, io.WriterTo) error Remove(string) error Keys() []string Rename(string, string) error }
Store represents the methods required for a Keystore
type String ¶
type String string
String is a string that implements io.ReaderFrom and io.WriterTo
type Uint ¶
type Uint uint
Uint is a uint that implements io.ReaderFrom and io.WriterTo
type Uint16 ¶
type Uint16 uint16
Uint16 is a uint16 that implements io.ReaderFrom and io.WriterTo
type Uint32 ¶
type Uint32 uint32
Uint32 is a uint32 that implements io.ReaderFrom and io.WriterTo
type Uint64 ¶
type Uint64 uint64
Uint64 is a uint64 that implements io.ReaderFrom and io.WriterTo