Documentation ¶
Overview ¶
Package dsmemcache handles Put, Get etc to Datastore and provides caching by memcached. How the cache is used is explained in the storagecache package's document.
Related document.
https://godoc.org/github.com/bradfitz/gomemcache/memcache https://godoc.org/go.mercari.io/datastore/dsmiddleware/storagecache
Index ¶
- func New(client *memcache.Client, opts ...CacheOption) interface{ ... }
- type CacheOption
- func WithCacheKey(f func(key datastore.Key) string) CacheOption
- func WithExcludeKinds(kinds ...string) CacheOption
- func WithExpireDuration(d time.Duration) CacheOption
- func WithIncludeKinds(kinds ...string) CacheOption
- func WithKeyFilter(f storagecache.KeyFilter) CacheOption
- func WithLogger(logf func(ctx context.Context, format string, args ...interface{})) CacheOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(client *memcache.Client, opts ...CacheOption) interface { datastore.Middleware storagecache.Storage }
New dsmemcache middleware creates & returns.
Types ¶
type CacheOption ¶
type CacheOption interface {
Apply(*cacheHandler)
}
A CacheOption is an cache option for a dsmemcache middleware.
func WithCacheKey ¶
func WithCacheKey(f func(key datastore.Key) string) CacheOption
WithCacheKey creates a ClientOption that specifies how to generate a cache key from datastore.Key.
func WithExcludeKinds ¶
func WithExcludeKinds(kinds ...string) CacheOption
WithExcludeKinds creates a ClientOption that selects the Kind unspecified as the cache target.
func WithExpireDuration ¶
func WithExpireDuration(d time.Duration) CacheOption
WithExpireDuration creates a ClientOption to expire at a specified time.
func WithIncludeKinds ¶
func WithIncludeKinds(kinds ...string) CacheOption
WithIncludeKinds creates a ClientOption that selects the Kind specified as the cache target.
func WithKeyFilter ¶
func WithKeyFilter(f storagecache.KeyFilter) CacheOption
WithKeyFilter creates a ClientOption that selects the Keys specified as the cache target.
func WithLogger ¶
func WithLogger(logf func(ctx context.Context, format string, args ...interface{})) CacheOption
WithLogger creates a ClientOption that uses the specified logger.