requestcache

package
v0.0.0-...-1b8c519 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2015 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithRequestCache

func WithRequestCache(ctx context.Context) context.Context

Types

type ExecutedCommand

type ExecutedCommand struct {
	// contains filtered or unexported fields
}

ExecutedCommand holds a response or response error and the execution info of the previously executed command.

func (*ExecutedCommand) ExecutionInfo

func (c *ExecutedCommand) ExecutionInfo() *requestlog.ExecutionInfo

ExecutionInfo returns an ExecutionInfo for the executed command. Execution time for cached responses is always zero.

func (*ExecutedCommand) Response

func (c *ExecutedCommand) Response() (interface{}, error)

Response returns a response or error stored from command execution.

type RequestCache

type RequestCache struct {
	// contains filtered or unexported fields
}

ResponseCache is a cache of command responses. It is safe to access ResponseCache from multiple thread.

func FromContext

func FromContext(ctx context.Context) *RequestCache

func (*RequestCache) Add

func (c *RequestCache) Add(
	name, key string,
	info requestlog.ExecutionInfo,
	r interface{},
	err error)

Add adds a command response and execution info to the cache to be reused by later executions of the command.

func (*RequestCache) Get

func (c *RequestCache) Get(name, key string) *ExecutedCommand

Get performs a lookup in the cache for the cached command with the given name and key. If no previous execution is in the cache nil is returned.

Jump to

Keyboard shortcuts

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