Documentation
¶
Index ¶
- Constants
- Variables
- type CacheItem
- type Clock
- type Counter
- type DiskLRU
- func (self *DiskLRU) Close() error
- func (self *DiskLRU) Debug(msg string, args ...interface{})
- func (self *DiskLRU) Delete(key string) bool
- func (self *DiskLRU) Dump()
- func (self *DiskLRU) Get(key string) (interface{}, error)
- func (self *DiskLRU) HouseKeepOnce()
- func (self *DiskLRU) Items() (res []CacheItem)
- func (self *DiskLRU) Peek(key string) (interface{}, error)
- func (self *DiskLRU) Purge() error
- func (self *DiskLRU) Set(key string, value interface{}) error
- func (self *DiskLRU) SetEncoder(encoder Encoder)
- func (self *DiskLRU) Stats() Stats
- type Encoder
- type JsonEncoder
- type Options
- type RealClock
- type Stats
Constants ¶
View Source
const (
NS = 1000000000
)
Variables ¶
View Source
var (
KeyNotFoundError = errors.New("Key not found error")
)
Functions ¶
This section is empty.
Types ¶
type Clock ¶
type Clock interface {
// Returns the time in nanosec since the epoch
// e.g. time.Now().UnixNano()
Now() int64
}
type DiskLRU ¶
type DiskLRU struct {
// contains filtered or unexported fields
}
func (*DiskLRU) HouseKeepOnce ¶
func (self *DiskLRU) HouseKeepOnce()
func (*DiskLRU) SetEncoder ¶
type JsonEncoder ¶
type JsonEncoder struct{}
func (JsonEncoder) Decode ¶
func (self JsonEncoder) Decode(in []byte) (interface{}, error)
func (JsonEncoder) Encode ¶
func (self JsonEncoder) Encode(obj interface{}) ([]byte, error)
type Options ¶
type Options struct {
// Path to the sqlite cache file.
Filename string
// Clear the file on start
ClearOnStart bool
// The maximum number of items to keep in cache
MaxSize int
// How long to keep items in cache
MaxExpirySec int
// Should expiry time be updated on access?
UpdateExpiryOnAccess bool
// How often to run the housekeeping thread, negative number
// disables automatic housekeeping.
HouseKeepPeriodSec int64
// The clock is used to control time in tests etc.
Clock Clock
// Set for explicit debugging.
DEBUG bool
}
Control the behavious of the cache
func (*Options) UpdateDefaults ¶
func (self *Options) UpdateDefaults()
Set some reasonable defaults.
Click to show internal directories.
Click to hide internal directories.