Documentation ¶
Index ¶
- Constants
- Variables
- type Cache
- func (cache *Cache) AverageAccessTime() int64
- func (cache *Cache) Clear()
- func (cache *Cache) Del(key []byte) (affected bool)
- func (cache *Cache) DelInt(key int64) (affected bool)
- func (cache *Cache) EntryCount() (entryCount int64)
- func (cache *Cache) EvacuateCount() (count int64)
- func (cache *Cache) ExpiredCount() (count int64)
- func (cache *Cache) Get(key []byte) (value []byte, err error)
- func (cache *Cache) GetInt(key int64) (value []byte, err error)
- func (cache *Cache) HitCount() int64
- func (cache *Cache) HitRate() float64
- func (cache *Cache) LookupCount() int64
- func (cache *Cache) OverwriteCount() (overwriteCount int64)
- func (cache *Cache) ResetStatistics()
- func (cache *Cache) Set(key, value []byte, expireSeconds int) (err error)
- func (cache *Cache) SetInt(key int64, value []byte, expireSeconds int) (err error)
- type RingBuf
- func (rb *RingBuf) Begin() int64
- func (rb *RingBuf) Dump() []byte
- func (rb *RingBuf) End() int64
- func (rb *RingBuf) EqualAt(p []byte, off int64) bool
- func (rb *RingBuf) Evacuate(off int64, length int) (newOff int64)
- func (rb *RingBuf) ReadAt(p []byte, off int64) (n int, err error)
- func (rb *RingBuf) Resize(newSize int)
- func (rb *RingBuf) Size() int64
- func (rb *RingBuf) Skip(length int64)
- func (rb *RingBuf) String() string
- func (rb *RingBuf) Write(p []byte) (n int, err error)
- func (rb *RingBuf) WriteAt(p []byte, off int64) (n int, err error)
Constants ¶
View Source
const ENTRY_HDR_SIZE = 24
View Source
const HASH_ENTRY_SIZE = 16
Variables ¶
View Source
var ErrLargeEntry = errors.New("The entry size is larger than 1/1024 of cache size")
View Source
var ErrLargeKey = errors.New("The key is larger than 65535")
View Source
var ErrNotFound = errors.New("Entry not found")
View Source
var ErrOutOfRange = errors.New("out of range")
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
func NewCache ¶
The cache size will be set to 512KB at minimum. If the size is set relatively large, you should call `debug.SetGCPercent()`, set it to a much smaller value to limit the memory consumption and GC pause time.
func (*Cache) AverageAccessTime ¶
The average unix timestamp when a entry being accessed. Entries have greater access time will be evacuated when it is about to be overwritten by new value.
func (*Cache) EntryCount ¶
func (*Cache) EvacuateCount ¶
func (*Cache) ExpiredCount ¶
func (*Cache) LookupCount ¶
func (*Cache) OverwriteCount ¶
func (*Cache) ResetStatistics ¶
func (cache *Cache) ResetStatistics()
type RingBuf ¶
type RingBuf struct {
// contains filtered or unexported fields
}
Ring buffer has a fixed size, when data exceeds the size, old data will be overwritten by new data. It only contains the data in the stream from begin to end
func NewRingBuf ¶
func (*RingBuf) Evacuate ¶
Evacuate read the data at off, then write it to the the data stream, Keep it from being overwritten by new data.
Click to show internal directories.
Click to hide internal directories.