Documentation ¶
Index ¶
- Constants
- func FileWalker(c chan string, prefix string) func(path string, info os.FileInfo, err error) error
- type Backend
- type FileBackend
- func (b *FileBackend) Delete(key string) (err error)
- func (b *FileBackend) FileTranslateSimple(key string) string
- func (b *FileBackend) Get(key string) (data []byte, err error)
- func (b *FileBackend) Has(key string) bool
- func (b *FileBackend) Prepare(key string) (err error)
- func (b *FileBackend) Scan(prefix string) <-chan string
- func (b *FileBackend) Set(key string, data []byte) (err error)
- type Options
- type SqliteBackend
- func (b *SqliteBackend) Delete(key string) (err error)
- func (b *SqliteBackend) Get(key string) (data []byte, err error)
- func (b *SqliteBackend) Has(key string) bool
- func (b *SqliteBackend) Prepare(key string) (err error)
- func (b *SqliteBackend) Scan(prefix string) <-chan string
- func (b *SqliteBackend) Set(key string, data []byte) (err error)
- type TranslateFileFunc
- type TranslatePathFunc
Constants ¶
const ( // DefaultFileMode contains a secure default file mode DefaultFileMode = os.FileMode(0600) // DefaultPathMode contains a secure default path mode DefaultPathMode = os.FileMode(0700) )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Backend ¶
type Backend interface { Lock() RLock() RLocker() sync.Locker RUnlock() Unlock() Prepare(key string) error Has(key string) bool Get(key string) ([]byte, error) Set(key string, data []byte) error Delete(key string) error Scan(prefix string) <-chan string }
Backend interface defines methods for a storage back end
type FileBackend ¶
type FileBackend struct { sync.RWMutex Options Options Compress bool CompressLevel int Extension string TranslateFile TranslateFileFunc TranslatePath TranslatePathFunc }
FileBackend stores arbitrary data structures on disk as File formatted files.
func NewFileBackend ¶
func NewFileBackend(opt Options) (b *FileBackend, err error)
NewFileBackend initialises a new File storage backend.
func (*FileBackend) Delete ¶
func (b *FileBackend) Delete(key string) (err error)
Delete removes a key from the storage.
func (*FileBackend) FileTranslateSimple ¶
func (b *FileBackend) FileTranslateSimple(key string) string
FileTranslateSimple converts a key to key plus file extension.
func (*FileBackend) Get ¶
func (b *FileBackend) Get(key string) (data []byte, err error)
Get retrieves raw key data from the storage, ready to be unmarshaled.
func (*FileBackend) Has ¶
func (b *FileBackend) Has(key string) bool
Has returns a bool that indicates if the key exists.
func (*FileBackend) Prepare ¶
func (b *FileBackend) Prepare(key string) (err error)
Prepare makes sure the path where the key is stored exists prior to saving it.
func (*FileBackend) Scan ¶
func (b *FileBackend) Scan(prefix string) <-chan string
Scan returns a channel that receives keys that match prefix, in no particular order.
type Options ¶
type Options struct { Path string TranslatePath TranslatePathFunc TranslateFile TranslateFileFunc FileMode os.FileMode PathMode os.FileMode Extra map[string]interface{} }
Options ...
func NewOptions ¶
NewOptions creates a new Options structure for the given path, with defaults.
type SqliteBackend ¶
func NewSqliteBackend ¶
func NewSqliteBackend(opt Options) (b *SqliteBackend, err error)
func (*SqliteBackend) Delete ¶
func (b *SqliteBackend) Delete(key string) (err error)
Delete removes a row from the table.
func (*SqliteBackend) Get ¶
func (b *SqliteBackend) Get(key string) (data []byte, err error)
Get retrieves raw key data from the storage, ready to be unmarshaled.
func (*SqliteBackend) Has ¶
func (b *SqliteBackend) Has(key string) bool
Has returns a bool that indicates if the key exists.
func (*SqliteBackend) Prepare ¶
func (b *SqliteBackend) Prepare(key string) (err error)
Prepare makes sure the path where the key is stored exists prior to saving it.
func (*SqliteBackend) Scan ¶
func (b *SqliteBackend) Scan(prefix string) <-chan string
Scan returns a channel that receives keys that match prefix, in no particular order.
type TranslateFileFunc ¶
TranslateFileFunc translates a key to a file path to the key file without its path.
type TranslatePathFunc ¶
TranslatePathFunc translates a key to a directory that contains the key file.