cache

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const VersionName = "0.1.0"

Variables

This section is empty.

Functions

func Register

func Register(name string, store Store)

Register registers a store.

func Version

func Version() string

Types

type AdapterConfig

type AdapterConfig struct {
	Addr     string
	Password string
	DB       int
}

type Cache

type Cache struct {
	Opt Options
	// contains filtered or unexported fields
}

func NewCache

func NewCache(alias string, options ...Options) (*Cache, error)

func (*Cache) Client added in v0.5.1

func (this *Cache) Client() interface{}

func (*Cache) Connect

func (this *Cache) Connect(opt Options) error

func (*Cache) Decr

func (this *Cache) Decr(key string) int64

func (*Cache) Delete

func (this *Cache) Delete(key string)

func (*Cache) DeleteByPrefix

func (this *Cache) DeleteByPrefix(prefix string)

func (*Cache) Flush

func (this *Cache) Flush()

func (*Cache) Get

func (this *Cache) Get(key string) string

func (*Cache) Incr

func (this *Cache) Incr(key string) int64

func (*Cache) IsExist

func (this *Cache) IsExist(key string) bool

func (*Cache) Key added in v0.5.2

func (this *Cache) Key(key string) string

func (*Cache) Set

func (this *Cache) Set(key, val string, expiration time.Duration)

func (*Cache) Touch

func (this *Cache) Touch(key string)

type MemoryCache

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

MemoryCache represents a memory cache adapter implementation.

func NewMemoryCache

func NewMemoryCache() *MemoryCache

NewMemoryCache creates and returns a new memory cache.

func (*MemoryCache) Client added in v0.5.0

func (r *MemoryCache) Client() interface{}

func (*MemoryCache) Connect

func (c *MemoryCache) Connect(opt Options) error

func (*MemoryCache) Decr

func (c *MemoryCache) Decr(key string) int64

Decr decreases cached int-type value by given key as a counter.

func (*MemoryCache) Delete

func (c *MemoryCache) Delete(key string)

Delete deletes cached value by given key.

func (*MemoryCache) DeleteByPrefix

func (c *MemoryCache) DeleteByPrefix(prefix string)

Delete deletes cached value by given prefix.

func (*MemoryCache) Flush

func (c *MemoryCache) Flush()

Flush deletes all cached data.

func (*MemoryCache) Forever

func (c *MemoryCache) Forever(key, val string) error

put value into cache with key forever save

func (*MemoryCache) Get

func (c *MemoryCache) Get(key string) string

Get gets cached value by given key.

func (*MemoryCache) Incr

func (c *MemoryCache) Incr(key string) int64

Incr increases cached int-type value by given key as a counter.

func (*MemoryCache) IsExist

func (c *MemoryCache) IsExist(key string) bool

IsExist returns true if cached value exists.

func (*MemoryCache) Key added in v0.5.2

func (r *MemoryCache) Key(key string) string

func (*MemoryCache) Set

func (c *MemoryCache) Set(key, val string, expiration time.Duration)

Set puts value into cache with key and expire time.

func (*MemoryCache) Touch

func (c *MemoryCache) Touch(key string)

update expire time

type MemoryItem

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

MemoryItem represents a memory cache item.

type Options

type Options struct {
	// Name of adapter. Default is "redis".
	Adapter string
	// Adapter configuration, it's corresponding to adapter.
	AdapterConfig AdapterConfig
	// key prefix Default is ""
	Section string
}

type RedisCache

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

func NewRedisCache

func NewRedisCache() *RedisCache

NewRedisCache creates and returns a new redis cache.

func (*RedisCache) Client added in v0.5.0

func (r *RedisCache) Client() interface{}

func (*RedisCache) Connect

func (r *RedisCache) Connect(opt Options) error

func (*RedisCache) Decr

func (r *RedisCache) Decr(key string) int64

Decr decreases cached int-type value by given key as a counter.

func (*RedisCache) Delete

func (r *RedisCache) Delete(key string)

Delete deletes cached value by given key.

func (*RedisCache) DeleteByPrefix

func (r *RedisCache) DeleteByPrefix(prefix string)

Delete deletes cached value by given prefix key.

func (*RedisCache) Flush

func (r *RedisCache) Flush()

Flush deletes all cached data.

func (*RedisCache) Get

func (r *RedisCache) Get(key string) string

func (*RedisCache) Incr

func (r *RedisCache) Incr(key string) int64

Incr increases cached int-type value by given key as a counter.

func (*RedisCache) IsExist

func (r *RedisCache) IsExist(key string) bool

IsExist returns true if cached value exists.

func (*RedisCache) Key added in v0.5.2

func (r *RedisCache) Key(key string) string

func (*RedisCache) Set

func (r *RedisCache) Set(key, val string, expiration time.Duration)

func (*RedisCache) Touch

func (r *RedisCache) Touch(key string)

update expire time

type Store

type Store interface {
	// Connect based on config string settings.
	Connect(opt Options) error
	// Client get client
	Client() interface{}
	// Key key
	Key(key string) string
	// Set puts value into cache with key and expire time.
	Set(key, val string, expiration time.Duration)
	// Get gets cached value by given key.
	Get(key string) string
	// Delete deletes cached value by given key.
	Delete(key string)
	// DeleteByPrefix deletes cached value by given prefix.
	DeleteByPrefix(prefix string)
	// Incr increases cached int-type value by given key as a counter.
	Incr(key string) int64
	// Decr decreases cached int-type value by given key as a counter.
	Decr(key string) int64
	// IsExist returns true if cached value exists.
	IsExist(key string) bool
	// Touch touch
	Touch(key string)
	// Flush deletes all cached data.
	Flush()
}

Store Cache is the interface that operates the cache data.

Jump to

Keyboard shortcuts

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