cache

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2018 License: MPL-2.0 Imports: 4 Imported by: 0

README

Cache - Small Opiniated Cache Library for Go

Build Status Go Report Card codecov

Small Opiniated Cache for Go. Still work in progress.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Clear() error
	Evict(key string) error
	Get(key string) ([]byte, error)
	Put(key string, value []byte, ttl time.Duration) error
	PutIfAbsent(key string, value []byte, ttl time.Duration) error
	Close() error
}

type MapCache

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

func NewMapCache

func NewMapCache() (*MapCache, error)

func NewMapCacheWithConfig

func NewMapCacheWithConfig(config MapCacheConfig) (*MapCache, error)

func (*MapCache) Clear

func (c *MapCache) Clear() error

func (*MapCache) Close

func (c *MapCache) Close() error

func (*MapCache) Evict

func (c *MapCache) Evict(key string) error

func (*MapCache) Get

func (c *MapCache) Get(key string) ([]byte, error)

func (*MapCache) Put

func (c *MapCache) Put(key string, value []byte, ttl time.Duration) error

func (*MapCache) PutIfAbsent

func (c *MapCache) PutIfAbsent(key string, value []byte, ttl time.Duration) error

type MapCacheConfig

type MapCacheConfig struct {
	ExpirationInterval time.Duration
}

type RedisCache

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

func NewRedisCache

func NewRedisCache() (*RedisCache, error)

func NewRedisCacheWithConfig

func NewRedisCacheWithConfig(config RedisCacheConfig) (*RedisCache, error)

func (*RedisCache) Clear

func (c *RedisCache) Clear() error

func (*RedisCache) Close

func (c *RedisCache) Close() error

func (*RedisCache) Evict

func (c *RedisCache) Evict(key string) error

func (*RedisCache) Get

func (c *RedisCache) Get(key string) ([]byte, error)

func (*RedisCache) Put

func (c *RedisCache) Put(key string, value []byte, ttl time.Duration) error

func (*RedisCache) PutIfAbsent

func (c *RedisCache) PutIfAbsent(key string, value []byte, ttl time.Duration) error

type RedisCacheConfig

type RedisCacheConfig struct {
	Addr     string
	Password string
	Prefix   string
}

Jump to

Keyboard shortcuts

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