Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithNumRings ¶
WithNumRings() sets number of rings used in cache. Defaults to 512. Sets to 1 if lower is set.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a thread-safe, memory KV cache similar to https://github.com/VictoriaMetrics/fastcache, created to be self-educational. Use fastcache instead if aiming for production use.
Key and value total length must not exceed (64KB - 4B).
func (*Cache) Get ¶
Get() copies value for key k into dst[:len(value)]. A new slice will be allocated if dst is nil or not long enough. Returns nil if not found.
func (*Cache) Has ¶
Has() checks whether key k exists in cache.
Has() is slightly cheaper than HasGet() and Get().
func (*Cache) HasGet ¶
HasGet() copies value for key k into dst[:len(value)] if pair exists. A new slice will be allocated if dst is nil or not long enough. Returns nil, false if not found.
HasGet() is equal to Get() in performance.
func (*Cache) Set ¶
Set() sets k, v into the cache. KV pairs with total length exceeding (64KB - 4B) are silently dropped.
k and v are safe to be modified after Set() returns
func (*Cache) Statistics ¶ added in v0.1.2
func (c *Cache) Statistics() Statistics
Statistics() reports cache performance statistics
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator