cache

package
v0.0.0-...-ee1864c Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackgroundConfig

type BackgroundConfig struct {
	WriteBackGoroutines int
	WriteBackBuffer     int
}

BackgroundConfig is config for a Background Cache.

func (*BackgroundConfig) RegisterFlags

func (cfg *BackgroundConfig) RegisterFlags(f *flag.FlagSet)

RegisterFlags adds the flags required to config this to the given FlagSet.

type Cache

type Cache interface {
	StoreChunk(ctx context.Context, key string, buf []byte) error
	FetchChunkData(ctx context.Context, keys []string) (found []string, bufs [][]byte, missing []string, err error)
	Stop() error
}

Cache byte arrays by key.

func New

func New(cfg Config) (Cache, error)

New creates a new Cache using Config.

func NewBackground

func NewBackground(cfg BackgroundConfig, cache Cache) Cache

NewBackground returns a new Cache that does stores on background goroutines.

func NewTiered

func NewTiered(caches []Cache) Cache

NewTiered makes a new tiered cache.

type Config

type Config struct {
	EnableDiskcache bool
	// contains filtered or unexported fields
}

Config for building Caches.

func (*Config) RegisterFlags

func (cfg *Config) RegisterFlags(f *flag.FlagSet)

RegisterFlags adds the flags required to config this to the given FlagSet.

type Diskcache

type Diskcache struct {
	// contains filtered or unexported fields
}

Diskcache is an on-disk chunk cache.

func NewDiskcache

func NewDiskcache(cfg DiskcacheConfig) (*Diskcache, error)

NewDiskcache creates a new on-disk cache.

func (*Diskcache) FetchChunkData

func (d *Diskcache) FetchChunkData(ctx context.Context, keys []string) (found []string, bufs [][]byte, missed []string, err error)

FetchChunkData get chunks from the cache.

func (*Diskcache) Stop

func (d *Diskcache) Stop() error

Stop closes the file.

func (*Diskcache) StoreChunk

func (d *Diskcache) StoreChunk(ctx context.Context, key string, value []byte) error

StoreChunk puts a chunk into the cache.

type DiskcacheConfig

type DiskcacheConfig struct {
	Path string
	Size int
}

DiskcacheConfig for the Disk cache.

func (*DiskcacheConfig) RegisterFlags

func (cfg *DiskcacheConfig) RegisterFlags(f *flag.FlagSet)

RegisterFlags adds the flags required to config this to the given FlagSet

type Memcached

type Memcached struct {
	// contains filtered or unexported fields
}

Memcached type caches chunks in memcached

func NewMemcached

func NewMemcached(cfg MemcachedConfig, client MemcachedClient) *Memcached

NewMemcached makes a new Memcache

func (*Memcached) FetchChunkData

func (c *Memcached) FetchChunkData(ctx context.Context, keys []string) (found []string, bufs [][]byte, missed []string, err error)

FetchChunkData gets chunks from the chunk cache.

func (*Memcached) Stop

func (*Memcached) Stop() error

Stop does nothing.

func (*Memcached) StoreChunk

func (c *Memcached) StoreChunk(ctx context.Context, key string, buf []byte) error

StoreChunk serializes and stores a chunk in the chunk cache.

type MemcachedClient

type MemcachedClient interface {
	GetMulti(keys []string) (map[string]*memcache.Item, error)
	Set(item *memcache.Item) error
}

MemcachedClient interface exists for mocking memcacheClient.

type MemcachedClientConfig

type MemcachedClientConfig struct {
	Host           string
	Service        string
	Timeout        time.Duration
	UpdateInterval time.Duration
}

MemcachedClientConfig defines how a MemcachedClient should be constructed.

func (*MemcachedClientConfig) RegisterFlags

func (cfg *MemcachedClientConfig) RegisterFlags(f *flag.FlagSet)

RegisterFlags adds the flags required to config this to the given FlagSet

type MemcachedConfig

type MemcachedConfig struct {
	Expiration time.Duration
}

MemcachedConfig is config to make a Memcached

func (*MemcachedConfig) RegisterFlags

func (cfg *MemcachedConfig) RegisterFlags(f *flag.FlagSet)

RegisterFlags adds the flags required to config this to the given FlagSet

Jump to

Keyboard shortcuts

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