...
Package lrucache
Package lrucache provides a byte-size-limited implementation of
httpcache.Cache that stores data in memory.
In the call graph viewer below, each node
is a function belonging to this package
and its children are the functions it
calls—perhaps dynamically.
The root nodes are the entry points of the
package: functions that may be called from
outside the package.
There may be non-exported or anonymous
functions among them if they are called
dynamically from another package.
Click a node to visit that function's source code.
From there you can visit its callers by
clicking its declaring func
token.
Functions may be omitted if they were
determined to be unreachable in the
particular programs or tests that were
analyzed.
type LruCache struct {
MaxSize int64
MaxAge int64
}
LruCache is a thread-safe, in-memory httpcache.Cache that evicts the
least recently used entries from memory when either MaxSize (in bytes)
limit would be exceeded or (if set) the entries are older than MaxAge (in
seconds). Use the New constructor to create one.
func New(maxSize int64, maxAge int64) *LruCache
New creates an LruCache that will restrict itself to maxSize bytes of
memory. If maxAge > 0, entries will also be expired after maxAge
seconds.
func (*LruCache) Delete
func (c *LruCache) Delete(key string)
Delete removes the value associated with a key.
func (*LruCache) Get
func (c *LruCache) Get(key string) ([]byte, bool)
Get returns the []byte representation of a cached response and a bool
set to true if the key was found.
func (*LruCache) Set
func (c *LruCache) Set(key string, value []byte)
Set stores the []byte representation of a response for a given key.
func (*LruCache) Size
func (c *LruCache) Size() int64
Size returns the estimated current memory usage of LruCache.
Subdirectories
Name |
Synopsis |
.. |
twotier
|
Package twotier provides a wrapper for two httpcache.Cache instances, allowing you to use both a small and fast cache for popular objects and fall back to a larger and slower cache for less popular ones.
|