lrucache: Index | Files

package twotier

import ""

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.


Package Files


type TwoTier Uses

type TwoTier struct {
    // contains filtered or unexported fields

TwoTier creates a two-tiered cache out of two httpcache.Cache instances. Reads are favored from first, and writes affect both first and second.

func New Uses

func New(first, second httpcache.Cache) *TwoTier

New creates a TwoTier. Both first and second must be non-nil.

func (*TwoTier) Delete Uses

func (c *TwoTier) Delete(key string)

Delete removes the value associated with a key from both the first and second tier caches.

func (*TwoTier) Get Uses

func (c *TwoTier) 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. It tries the first tier cache, and if that's not successful, copies the result from the second tier into the first tier.

func (*TwoTier) Set Uses

func (c *TwoTier) Set(key string, value []byte)

Set stores the []byte representation of a response for a given key into the second tier cache, and deletes the cache entry from the first tier cache.

Package twotier imports 1 packages (graph) and is imported by 3 packages. Updated 2019-02-06. Refresh now. Tools for package owners.