bcache

package module
v0.0.0-...-61825aa Latest Latest
Warning

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

Go to latest
Published: May 30, 2021 License: MIT Imports: 15 Imported by: 0

README

bcache

Spike for building the most effective cache solution.

The goals:

  • choose the serialization approach
  • local cache
  • remote cache

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCacheMiss = errors.New("key miss")

Functions

This section is empty.

Types

type BigCacheCache

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

func (*BigCacheCache) Get

func (c *BigCacheCache) Get(key string) ([]byte, bool)

func (*BigCacheCache) Remove

func (c *BigCacheCache) Remove(key string)

func (*BigCacheCache) Set

func (c *BigCacheCache) Set(key string, value []byte)

type BufferedMsgPackCoder

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

func (*BufferedMsgPackCoder) Decode

func (b *BufferedMsgPackCoder) Decode(buf []byte, value interface{}) error

func (*BufferedMsgPackCoder) Encode

func (b *BufferedMsgPackCoder) Encode(value interface{}) ([]byte, error)

type CCacheCache

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

func (*CCacheCache) Get

func (c *CCacheCache) Get(key string) ([]byte, bool)

func (*CCacheCache) Remove

func (c *CCacheCache) Remove(key string)

func (*CCacheCache) Set

func (c *CCacheCache) Set(key string, value []byte)

type Client

type Client interface {
	Get(ctx context.Context, key string, value interface{}) error
	Set(ctx context.Context, key string, value interface{}) error
	Remove(ctx context.Context, key string) error
}

func NewClient

func NewClient(cfg Config) Client

type Coder

type Coder interface {
	Decode(buf []byte, value interface{}) error
	Encode(value interface{}) ([]byte, error)
}

func NewBufferedMsgPackCoder

func NewBufferedMsgPackCoder() Coder

type Config

type Config struct {
	Coder  Coder
	Local  LocalCache
	Remote RemoteCache
}

type FreeCacheCache

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

func (*FreeCacheCache) Get

func (c *FreeCacheCache) Get(key string) ([]byte, bool)

func (*FreeCacheCache) Remove

func (c *FreeCacheCache) Remove(key string)

func (*FreeCacheCache) Set

func (c *FreeCacheCache) Set(key string, value []byte)

type JsonCoder

type JsonCoder struct{}

func (JsonCoder) Decode

func (JsonCoder) Decode(buf []byte, value interface{}) error

func (JsonCoder) Encode

func (JsonCoder) Encode(value interface{}) ([]byte, error)

type LocalCache

type LocalCache interface {
	Get(key string) ([]byte, bool)
	Set(key string, value []byte)
	Remove(key string)
}

func NewBigCacheCache

func NewBigCacheCache() LocalCache

func NewCCacheCache

func NewCCacheCache() LocalCache

func NewFreeCacheCache

func NewFreeCacheCache() LocalCache

func NewRistrettoCache

func NewRistrettoCache() LocalCache

func NewSimpleLRUCache

func NewSimpleLRUCache() LocalCache

type RedisCache

type RedisCache struct {
	TTL    time.Duration
	Client redisClient
}

func (*RedisCache) Get

func (r *RedisCache) Get(ctx context.Context, key string) ([]byte, error)

func (*RedisCache) Remove

func (r *RedisCache) Remove(ctx context.Context, key string) error

func (*RedisCache) Set

func (r *RedisCache) Set(ctx context.Context, key string, value []byte) error

type RemoteCache

type RemoteCache interface {
	Set(ctx context.Context, key string, value []byte) error
	Get(ctx context.Context, key string) ([]byte, error)
	Remove(ctx context.Context, key string) error
}

type RistrettoCache

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

func (*RistrettoCache) Get

func (c *RistrettoCache) Get(key string) ([]byte, bool)

func (*RistrettoCache) Remove

func (c *RistrettoCache) Remove(key string)

func (*RistrettoCache) Set

func (c *RistrettoCache) Set(key string, value []byte)

type SimpleLRUCache

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

func (*SimpleLRUCache) Get

func (c *SimpleLRUCache) Get(key string) ([]byte, bool)

func (*SimpleLRUCache) Remove

func (c *SimpleLRUCache) Remove(key string)

func (*SimpleLRUCache) Set

func (c *SimpleLRUCache) Set(key string, value []byte)

type VanillaMsgPackCoder

type VanillaMsgPackCoder struct{}

func (VanillaMsgPackCoder) Decode

func (VanillaMsgPackCoder) Decode(buf []byte, value interface{}) error

func (VanillaMsgPackCoder) Encode

func (VanillaMsgPackCoder) Encode(value interface{}) ([]byte, error)

Jump to

Keyboard shortcuts

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