cacheservice

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// DefaultCacheService decides the default cache service connection.
	DefaultCacheService string
)

Functions

func Register

func Register(name string, fn NewConnFunc)

Register a db connection.

Types

type CacheService

type CacheService interface {
	// Get returns cached data for given keys.
	Get(keys ...string) (results []Result, err error)
	// Gets returns cached data for given keys, it is an alternative Get api
	// for using with CAS. Gets returns a CAS identifier with the item. If
	// the item's CAS value has changed since you Gets'ed it, it will not be stored.
	Gets(keys ...string) (results []Result, err error)
	// Set sets the value with specified cache key.
	Set(key string, flags uint16, timeout uint64, value []byte) (stored bool, err error)
	// Add stores the value only if it does not already exist.
	Add(key string, flags uint16, timeout uint64, value []byte) (stored bool, err error)
	// Replace replaces the value, only if the value already exists,
	// for the specified cache key.
	Replace(key string, flags uint16, timeout uint64, value []byte) (stored bool, err error)
	// Append appends the value after the last bytes in an existing item.
	Append(key string, flags uint16, timeout uint64, value []byte) (stored bool, err error)
	// Prepend prepends the value before existing value.
	Prepend(key string, flags uint16, timeout uint64, value []byte) (stored bool, err error)
	// Cas stores the value only if no one else has updated the data since you read it last.
	Cas(key string, flags uint16, timeout uint64, value []byte, cas uint64) (stored bool, err error)
	// Delete deletes the value for the specified cache key.
	Delete(key string) (deleted bool, err error)
	// FlushAll purges the entire cache.
	FlushAll() (err error)
	// Stats returns a list of basic stats.
	Stats(argument string) (result []byte, err error)
	// Close closes the CacheService
	Close()
}

CacheService defines functions to use a cache service.

func Connect

func Connect(config Config) (CacheService, error)

Connect returns a CacheService using the given config.

type Config

type Config struct {
	Address string
	Timeout time.Duration
}

Config carries config data for CacheService.

type NewConnFunc

type NewConnFunc func(config Config) (CacheService, error)

NewConnFunc is a factory method that creates a CacheService instance using given CacheServiceConfig.

type Result

type Result struct {
	Key   string
	Value []byte
	Flags uint16
	Cas   uint64
}

Result gives the cached data.

Jump to

Keyboard shortcuts

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