cache

package
v1.4.41 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequiresParameters

func RequiresParameters(name Backend) bool

RequiresParameters returns true if the backend requires config parameters

func Validate

func Validate(name Backend) error

Validate validates the config

Types

type Backend

type Backend string

Backend cache

const (

	// MemoryBackend is a memory cache backend
	MemoryBackend Backend = "memory"
	// MemcachedBackend is a memcache cache backend
	MemcachedBackend Backend = "memcached"
	// RedisBackend is a redis cache backend
	RedisBackend Backend = "redis"
)

type Cache

type Cache interface {
	Init() error
	Add(key string, data interface{}) error
	Get(key string, output interface{}) error
	Del(key string) error
	Exists(key string) (bool, error)
}

Cache stores the state of the OAuth2 flow.

func NewFromArgs

func NewFromArgs(config *Config) Cache

NewFromArgs creates a new cache backend from the supplied arguments

type Config

type Config struct {
	Backend Backend
	Config  []string
}

Config stores a simple config to initialize the backend once again

type Memcached

type Memcached struct {
	Servers []string
	// contains filtered or unexported fields
}

Memcached implements StateManager interface using memcached as backend.

func NewMemcachedCache

func NewMemcachedCache(server ...string) *Memcached

NewMemcachedCache creates a new key manager using the specified servers.

func (*Memcached) Add

func (sm *Memcached) Add(key string, value interface{}) error

Add a key and its value to the backend.

func (*Memcached) Del

func (sm *Memcached) Del(key string) error

Del deletes a key from the backend.

func (*Memcached) Exists

func (sm *Memcached) Exists(key string) (bool, error)

Exists checks if the key exists in the backend.

func (*Memcached) Get

func (sm *Memcached) Get(key string, output interface{}) error

Get gets a value from the cache already casted to your type.

func (*Memcached) Init

func (sm *Memcached) Init() error

Init makes sure the memcached connection is valid.

func (*Memcached) String

func (sm *Memcached) String() string

type Memory

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

Memory is a state store that stores state in memory on the current process.

func NewMemoryCache

func NewMemoryCache() *Memory

NewMemoryCache creates a new in memory cache.

func (*Memory) Add

func (sm *Memory) Add(key string, value interface{}) error

Add a new key to the store.

func (*Memory) Del

func (sm *Memory) Del(key string) error

Del deletes a state from the store.

func (*Memory) Exists

func (sm *Memory) Exists(key string) (bool, error)

Exists checks if a state exists in the store.

func (*Memory) Get

func (sm *Memory) Get(key string, output interface{}) error

Get gets a value from the cache already casted to your type.

func (*Memory) Init

func (sm *Memory) Init() error

Init initializes a memory cleanup routine.

func (*Memory) String

func (sm *Memory) String() string

type Redis

type Redis struct {
	Servers []string
	// contains filtered or unexported fields
}

Redis implements StateManager interface using redis as backend.

func NewRedisCache

func NewRedisCache(server []string) *Redis

NewRedisCache creates a new key manager using the specified servers.

func (*Redis) Add

func (sm *Redis) Add(key string, value interface{}) error

Add a key and its value to the backend.

func (*Redis) Del

func (sm *Redis) Del(key string) error

Del deletes a key from the backend.

func (*Redis) Exists

func (sm *Redis) Exists(key string) (bool, error)

Exists checks if the key exists in the backend.

func (*Redis) Get

func (sm *Redis) Get(key string, output interface{}) error

Get gets a value from the cache already cast to your type.

func (*Redis) Init

func (sm *Redis) Init() error

Init makes sure the redis connection is valid.

func (*Redis) String

func (sm *Redis) String() string

Jump to

Keyboard shortcuts

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