cachei

package module
v0.0.0-...-7db96e5 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2015 License: MIT Imports: 2 Imported by: 0

README

cachei

A generic cache interface for Go (golang) that has multiple backends for caching servers and encodings.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, driver Cacher)

Types

type CacheFunc

type CacheFunc func() (interface{}, error)

type Cacher

type Cacher interface {
	// Gets a cache value and instead of returning it, puts it into "out".
	// If no cache is found, the CacheFunc is called and put into cache.
	// It returns the CacheFunc error, and caching error
	OutSetFn(key string, expires int, out interface{}, cFunc CacheFunc) (funcErr error, cacheErr error)

	// Gets a cache value.
	// If no cache is found, the CacheFunc is called and put into cache.
	// It returns the CacheFunc error, and caching error
	GetSetFn(key string, expires int, cFunc CacheFunc) (ret interface{}, funcErr error, cacheErr error)

	Out(key string, out interface{}) (cacheErr error)
	Get(key string) (ret interface{}, cacheErr error)
	Set(key string, value interface{}, expires int) (cacheErr error)

	// Delete a key from the cache.
	// Returns a caching error.
	Delete(key string) (cacheErr error)

	Open() error
	Close() error
	Setup(DataSource) error
}

func Open

func Open(name string, settings DataSource) (Cacher, error)

func Wrapper

func Wrapper(name string) Cacher

type Coder

type Coder interface {
	Marshal(v interface{}) ([]byte, error)
	Unmarshal(data []byte, v interface{}) error
}

type DataSource

type DataSource struct {
	Host  string
	Port  int
	Coder Coder
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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