 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cacher ¶
Cacher returns a middleware handler that injects cache.Cache into the request context, which is used for manipulating cache data.
func GobEncoder ¶
GobEncoder is a cache data encoder using Gob.
Types ¶
type Cache ¶
type Cache interface {
	// Get returns the value of given key in the cache. It returns os.ErrNotExist if
	// no such key exists or the key has expired.
	Get(ctx context.Context, key string) (interface{}, error)
	// Set sets the value of the key with given lifetime in the cache.
	Set(ctx context.Context, key string, value interface{}, lifetime time.Duration) error
	// Delete deletes a key from the cache.
	Delete(ctx context.Context, key string) error
	// Flush wipes out all existing data in the cache.
	Flush(ctx context.Context) error
	// GC performs a GC operation on the cache store.
	GC(ctx context.Context) error
}
    Cache is a cache store with capabilities of setting, reading, deleting and GC cache data.
type FileConfig ¶
type FileConfig struct {
	// RootDir is the root directory of file cache items stored on the local file
	// system. Default is "cache".
	RootDir string
	// Encoder is the encoder to encode cache data. Default is a Gob encoder.
	Encoder Encoder
	// Decoder is the decoder to decode cache data. Default is a Gob decoder.
	Decoder Decoder
	// contains filtered or unexported fields
}
    FileConfig contains options for the file cache store.
type Initer ¶
Initer takes arbitrary number of arguments needed for initialization and returns an initialized cache store.
func MemoryIniter ¶
func MemoryIniter() Initer
MemoryIniter returns the Initer for the memory cache store.
type MemoryConfig ¶
type MemoryConfig struct {
	// contains filtered or unexported fields
}
    MemoryConfig contains options for the memory cache store.
type Options ¶
type Options struct {
	// Initer is the initialization function of the cache store. Default is
	// cache.MemoryIniter.
	Initer Initer
	// Config is the configuration object to be passed to the Initer for the cache
	// store.
	Config interface{}
	// GCInterval is the time interval for GC operations. Default is 5 minutes.
	GCInterval time.Duration
	// ErrorFunc is the function used to print errors when something went wrong on
	// the background. Default is to drop errors silently.
	ErrorFunc func(err error)
}
    Options contains options for the cache.Cacher middleware.
 Click to show internal directories. 
   Click to hide internal directories.