Documentation
¶
Overview ¶
Package cache (memcache.go) provides a caching abstraction layer that can work with different backends (in-memory, Redis, etc.) to replace appengine/memcache.
Index ¶
- Variables
- func IncrementExisting(ctx context.Context, key string, delta int64) (int64, error)
- func MemDelete(ctx context.Context, key string) error
- func MemGet(ctx context.Context, key string, dst interface{}) error
- func MemSet(ctx context.Context, item *Item) error
- func Set(ctx context.Context, item *Item) error
- type CacheError
- type Item
- type Memoized
- type MemoryCache
- func (c *MemoryCache) Delete(ctx context.Context, key string) error
- func (c *MemoryCache) Get(ctx context.Context, key string, dst interface{}) error
- func (c *MemoryCache) IncrementExisting(ctx context.Context, key string, delta int64) (int64, error)
- func (c *MemoryCache) Set(ctx context.Context, item *Item) error
Constants ¶
This section is empty.
Variables ¶
View Source
var Gob = &gobCodec{}
Gob provides Gob codec for cache operations (compatible with memcache.Gob) For simplicity, we use JSON internally
View Source
var JSON = &jsonCodec{}
JSON provides JSON codec for cache operations (compatible with memcache.JSON)
Functions ¶
func IncrementExisting ¶
IncrementExisting increments an existing counter in the default cache
Types ¶
type CacheError ¶
type CacheError string
Error types
const (
ErrCacheMiss CacheError = "cache: miss"
)
func (CacheError) Error ¶
func (e CacheError) Error() string
type Memoized ¶
type Memoized func(args ...interface{}) interface{}
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache is an in-memory cache implementation
func NewMemoryCache ¶
func NewMemoryCache() *MemoryCache
NewMemoryCache creates a new in-memory cache
func (*MemoryCache) Delete ¶
func (c *MemoryCache) Delete(ctx context.Context, key string) error
Delete removes an item from the cache
func (*MemoryCache) Get ¶
func (c *MemoryCache) Get(ctx context.Context, key string, dst interface{}) error
Get retrieves an item from the cache
func (*MemoryCache) IncrementExisting ¶
func (c *MemoryCache) IncrementExisting(ctx context.Context, key string, delta int64) (int64, error)
IncrementExisting increments an existing counter
Click to show internal directories.
Click to hide internal directories.