Documentation ¶
Index ¶
- type Cache
- type FIFO
- func (w FIFO) Add(key, value interface{}) (added bool)
- func (w FIFO) BatchGet(key ...interface{}) (vals []Value)
- func (w FIFO) BatchPut(pair ...interface{})
- func (w FIFO) Clear()
- func (w FIFO) Delete(key ...interface{}) (changed int)
- func (w FIFO) Get(key interface{}) (value interface{}, exists bool)
- func (w FIFO) Len() (count int)
- func (w FIFO) Put(key, value interface{})
- type FIFOOption
- type LFU
- func (w LFU) Add(key, value interface{}) (added bool)
- func (w LFU) BatchGet(key ...interface{}) (vals []Value)
- func (w LFU) BatchPut(pair ...interface{})
- func (w LFU) Clear()
- func (w LFU) Delete(key ...interface{}) (changed int)
- func (w LFU) Get(key interface{}) (value interface{}, exists bool)
- func (w LFU) Len() (count int)
- func (w LFU) Put(key, value interface{})
- type LFUOption
- type LRU
- func (w LRU) Add(key, value interface{}) (added bool)
- func (w LRU) BatchGet(key ...interface{}) (vals []Value)
- func (w LRU) BatchPut(pair ...interface{})
- func (w LRU) Clear()
- func (w LRU) Delete(key ...interface{}) (changed int)
- func (w LRU) Get(key interface{}) (value interface{}, exists bool)
- func (w LRU) Len() (count int)
- func (w LRU) Put(key, value interface{})
- type LRUK
- func (w LRUK) Add(key, value interface{}) (added bool)
- func (w LRUK) BatchGet(key ...interface{}) (vals []Value)
- func (w LRUK) BatchPut(pair ...interface{})
- func (w LRUK) Clear()
- func (w LRUK) Delete(key ...interface{}) (changed int)
- func (w LRUK) Get(key interface{}) (value interface{}, exists bool)
- func (w LRUK) Len() (count int)
- func (w LRUK) Put(key, value interface{})
- type LRUKOption
- func WithLRUK(k int) LRUKOption
- func WithLRUKCapacity(capacity int) LRUKOption
- func WithLRUKClear(duration time.Duration) LRUKOption
- func WithLRUKExpiry(expiry time.Duration) LRUKOption
- func WithLRUKHistory(history LowCache) LRUKOption
- func WithLRUKHistoryOnlyKey(onlyKey bool) LRUKOption
- func WithLRUKLRU(lru LowCache) LRUKOption
- type LRUOption
- type LowCache
- type LowFIFOOption
- type LowLFUOption
- type LowLRUK
- func (l *LowLRUK) Add(key, value interface{}) (added bool)
- func (l *LowLRUK) Clear()
- func (l *LowLRUK) ClearExpired()
- func (l *LowLRUK) Delete(key ...interface{}) (changed int)
- func (l *LowLRUK) Get(key interface{}) (value interface{}, exists bool)
- func (l *LowLRUK) Len() int
- func (l *LowLRUK) Put(key, value interface{}) (delkey, delval interface{}, deleted bool)
- type LowLRUKOption
- type LowLRUOption
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { // Add the value to the cache, only when the key does not exist Add(key, value interface{}) (added bool) // Put key value to cache Put(key, value interface{}) // Get return cache value Get(key interface{}) (value interface{}, exists bool) // BatchPut pairs to cache BatchPut(pair ...interface{}) // BatchGet return cache values BatchGet(key ...interface{}) (vals []Value) // Delete key from cache Delete(key ...interface{}) (changed int) // Len returns the number of cached data Len() (count int) // Clear all cached data Clear() }
type FIFO ¶
type FIFO struct {
// contains filtered or unexported fields
}
func NewFIFO ¶
func NewFIFO(opt ...FIFOOption) (fifo *FIFO)
func (FIFO) Add ¶
func (w FIFO) Add(key, value interface{}) (added bool)
Add the value to the cache, only when the key does not exist
func (FIFO) BatchGet ¶
func (w FIFO) BatchGet(key ...interface{}) (vals []Value)
BatchGet return cache values
type FIFOOption ¶
type FIFOOption interface {
// contains filtered or unexported methods
}
func WithFIFOCapacity ¶
func WithFIFOCapacity(capacity int) FIFOOption
WithFIFOCapacity set the maximum amount of data to be cached
func WithFIFOClear ¶
func WithFIFOClear(duration time.Duration) FIFOOption
WithFIFOClear timer clear expired cache, if <=0 not start timer.
func WithFIFOExpiry ¶
func WithFIFOExpiry(expiry time.Duration) FIFOOption
WithFIFOExpiry if <=0, it will not expire due to time
type LFU ¶
type LFU struct {
// contains filtered or unexported fields
}
func (LFU) Add ¶
func (w LFU) Add(key, value interface{}) (added bool)
Add the value to the cache, only when the key does not exist
func (LFU) BatchGet ¶
func (w LFU) BatchGet(key ...interface{}) (vals []Value)
BatchGet return cache values
type LFUOption ¶
type LFUOption interface {
// contains filtered or unexported methods
}
func WithLFUCapacity ¶
WithLFUCapacity set the maximum amount of data to be cached
func WithLFUClear ¶
WithLFUClear timer clear expired cache, if <=0 not start timer.
func WithLFUExpiry ¶
WithLFUExpiry if <=0, it will not expire due to time
type LRU ¶
type LRU struct {
// contains filtered or unexported fields
}
func (LRU) Add ¶
func (w LRU) Add(key, value interface{}) (added bool)
Add the value to the cache, only when the key does not exist
func (LRU) BatchGet ¶
func (w LRU) BatchGet(key ...interface{}) (vals []Value)
BatchGet return cache values
type LRUK ¶
type LRUK struct {
// contains filtered or unexported fields
}
func NewLRUK ¶
func NewLRUK(opt ...LRUKOption) (lruk *LRUK)
func (LRUK) Add ¶
func (w LRUK) Add(key, value interface{}) (added bool)
Add the value to the cache, only when the key does not exist
func (LRUK) BatchGet ¶
func (w LRUK) BatchGet(key ...interface{}) (vals []Value)
BatchGet return cache values
type LRUKOption ¶
type LRUKOption interface {
// contains filtered or unexported methods
}
func WithLRUK ¶
func WithLRUK(k int) LRUKOption
WithLRUK set lru-k ,if k == 1 use lru, if k >1 use lru-k, if < 1
func WithLRUKCapacity ¶
func WithLRUKCapacity(capacity int) LRUKOption
WithLRUKCapacity set the maximum amount of data to be cached
func WithLRUKClear ¶
func WithLRUKClear(duration time.Duration) LRUKOption
WithLRUKClear timer clear expired cache, if <=0 not start timer.
func WithLRUKExpiry ¶
func WithLRUKExpiry(expiry time.Duration) LRUKOption
WithLRUKExpiry if <=0, it will not expire due to time
func WithLRUKHistory ¶
func WithLRUKHistory(history LowCache) LRUKOption
WithLRUKHistory if history is nil use lru-1, default is nil.
func WithLRUKHistoryOnlyKey ¶
func WithLRUKHistoryOnlyKey(onlyKey bool) LRUKOption
WithLRUKHistoryOnlyKey if ture history only save key, if false history will save key and value
type LRUOption ¶
type LRUOption interface {
// contains filtered or unexported methods
}
func WithLRUCapacity ¶
WithLRUCapacity set the maximum amount of data to be cached
func WithLRUClear ¶
WithLRUClear timer clear expired cache, if <=0 not start timer.
func WithLRUExpiry ¶
WithLRUExpiry if <=0, it will not expire due to time
type LowCache ¶
type LowCache interface { // Clear Expired cache ClearExpired() // Add the value to the cache, only when the key does not exist Add(key, value interface{}) (added bool) // Put key value to cache Put(key, value interface{}) (delkey, delval interface{}, deleted bool) // Get return cache value Get(key interface{}) (value interface{}, exists bool) // Delete key from cache Delete(key ...interface{}) (changed int) // Len returns the number of cached data Len() int // Clear all cached data Clear() }
Low-level caching is usually only used when combining multiple caching algorithms
func NewLowFIFO ¶
func NewLowFIFO(opt ...LowFIFOOption) LowCache
NewLowFIFO create a low-level lru, use NewFIFO unless you know exactly what you are doing.
func NewLowLFU ¶
func NewLowLFU(opt ...LowLFUOption) LowCache
NewLowLFU create a low-level lfu, use NewLFU unless you know exactly what you are doing.
func NewLowLRU ¶
func NewLowLRU(opt ...LowLRUOption) LowCache
NewLowLRU create a low-level lru, use NewLRU unless you know exactly what you are doing.
type LowFIFOOption ¶
type LowFIFOOption interface {
// contains filtered or unexported methods
}
func WithLowFIFOCapacity ¶
func WithLowFIFOCapacity(capacity int) LowFIFOOption
WithLowFIFOCapacity set the maximum amount of data to be cached
func WithLowFIFOExpiry ¶
func WithLowFIFOExpiry(expiry time.Duration) LowFIFOOption
WithLowFIFOExpiry if <=0, it will not expire due to time
type LowLFUOption ¶
type LowLFUOption interface {
// contains filtered or unexported methods
}
func WithLowLFUCapacity ¶
func WithLowLFUCapacity(capacity int) LowLFUOption
WithLowLFUCapacity set the maximum amount of data to be cached
func WithLowLFUExpiry ¶
func WithLowLFUExpiry(expiry time.Duration) LowLFUOption
WithLowLFUExpiry if <=0, it will not expire due to time
type LowLRUK ¶
type LowLRUK struct {
// contains filtered or unexported fields
}
A low-level implementation of lruk, use LRUK unless you know exactly what you are doing.
func NewLowLRUK ¶
func NewLowLRUK(history, lru LowCache, opt ...LowLRUKOption) *LowLRUK
NewLowLRUK create a low-level lru, use NewLRUK unless you know exactly what you are doing.
type LowLRUKOption ¶
type LowLRUKOption interface {
// contains filtered or unexported methods
}
func WithLowLRUK ¶
func WithLowLRUK(k int) LowLRUKOption
WithLowLRUK set lru-k ,if k == 1 use lru, if k >1 use lru-k, if < 1
func WithLowLRUKHistoryOnlyKey ¶
func WithLowLRUKHistoryOnlyKey(onlyKey bool) LowLRUKOption
WithLowLRUKHistoryOnlyKey if ture history only save key, if false history will save key and value
type LowLRUOption ¶
type LowLRUOption interface {
// contains filtered or unexported methods
}
func WithLowLRUCapacity ¶
func WithLowLRUCapacity(capacity int) LowLRUOption
WithLRUCapacity set the maximum amount of data to be cached
func WithLowLRUExpiry ¶
func WithLowLRUExpiry(expiry time.Duration) LowLRUOption
WithLowLRUExpiry if <=0, it will not expire due to time