whcache

package
v1.0.0-...-3f30213 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2017 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Overview

Package whcache provides a mechanism for per-request computation caching

Sometimes you have a helper method that performs a computation or interacts with a datastore or remote resource, and that helper method gets called repeatedly. With simple context values, since the helper method is the most descendent frame in the stack, there isn't a context specific place (besides maybe the session, which would be a bad choice) to cache context specific values. With this cache helper, there now is.

The cache must be registered up the handler chain with Register, and then helper methods can use Set/Get/Remove to interact with the cache (if available). If no cache was registered, Set/Get/Remove will still work, but Get will never return a value.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(ctx context.Context, key interface{}) interface{}

Get returns previously stored key/value pairs from the context specific cache if one is registered and the value is found, and returns nil otherwise.

func Register

func Register(h http.Handler) http.Handler

Register installs a cache in the handler chain.

func Remove

func Remove(ctx context.Context, key interface{})

Remove removes any values stored with key from the context specific cache, if possible.

func Set

func Set(ctx context.Context, key, val interface{})

Set stores the key/val pair in the context specific cache, if possible.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL