Documentation
¶
Index ¶
- Variables
- func NewOrLoadIndexFile(dirpath string) (*indexFile, error)
- type FileStorage
- func (f *FileStorage) Delete(key string) (err error)
- func (f *FileStorage) Get(key string, dest interface{}) (err error)
- func (f *FileStorage) IsExpired(key string) (isExpired bool, err error)
- func (f *FileStorage) NoCacheGet(key string, dest interface{}) (err error)
- func (f *FileStorage) Set(key string, value interface{}, expiredAt *time.Time) (err error)
- type Storage
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidDir = errors.New("FileStorage: invalid dirpath given") ErrNoData = errors.New("FileStorage: no data") // file accessing methods returns this error when the given key has no data ErrExpired = errors.New("FileStorage: expired") // file accessing methods returns this error when the data is expired ErrLiveForever = errors.New("FileStorage: expiredAt is not set") // IsExpired method on FileStorage returns this error when expiredAt is nil for the key ErrIndexNotFound = errors.New("FileStorage: indexfile is not found") )
Functions ¶
func NewOrLoadIndexFile ¶
Types ¶
type FileStorage ¶
type FileStorage struct {
// contains filtered or unexported fields
}
func NewFileStorage ¶
func NewFileStorage(dirpath string) (storage *FileStorage, err error)
FileStorage creates the storage directory at dirpath to place the file into. NewFileStorage returns an error if it fails to prepare directory for the one.
func (*FileStorage) Delete ¶
func (f *FileStorage) Delete(key string) (err error)
Delete removes the file and the data from the cache
func (*FileStorage) Get ¶
func (f *FileStorage) Get(key string, dest interface{}) (err error)
Get scans the stored value from FileStorage into the destination pointer. An error is returned if the data is not stored or has already expired.
func (*FileStorage) IsExpired ¶
func (f *FileStorage) IsExpired(key string) (isExpired bool, err error)
IsExpired checks whether the stored data is expired. ErrLiveForever is returns if expiredAt is not set.
func (*FileStorage) NoCacheGet ¶
func (f *FileStorage) NoCacheGet(key string, dest interface{}) (err error)
Get scans the stored value from the stored file into the destination pointer. An error is returned if the data is not stored or has already expired.
type Storage ¶
type Storage interface {
Get(key string, dest interface{}) error
NoCacheGet(key string, dest interface{}) error
IsExpired(key string) (isExpired bool, err error)
Set(key string, value interface{}, expiredAt *time.Time) error
Delete(key string) error
}
A storage with cache implementation
Click to show internal directories.
Click to hide internal directories.