rediscache

package
v0.0.0-...-2c17daf Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2021 License: MIT Imports: 5 Imported by: 0

README

rediscache 基于 redis 的缓存驱动

Documentation

Overview

Package rediscache provides cache driver uses redis to store cache data. Using github.com/garyburd/redigo/redis as driver.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	cache.DriverUtil
	Pool *redis.Pool //Redis pool.

	Separtor string //Separtor in redis key.
	// contains filtered or unexported fields
}

Cache The redis cache Driver.

func (*Cache) Close

func (c *Cache) Close() error

Close Close cache. Return any error if raised

func (*Cache) Del

func (c *Cache) Del(key string) error

Del Delete data in cache by given key. Return any error raised.

func (*Cache) DelCounter

func (c *Cache) DelCounter(key string) error

DelCounter Delete int val in cache by given key.Count cache and data cache are in two independent namespace. Return any error raised.

func (*Cache) Expire

func (c *Cache) Expire(key string, ttl time.Duration) error

Expire set cache value expire duration by given key and ttl

func (*Cache) ExpireCounter

func (c *Cache) ExpireCounter(key string, ttl time.Duration) error

ExpireCounter set cache counter expire duration by given key and ttl

func (*Cache) Flush

func (c *Cache) Flush() error

Flush Flush not supported.

func (*Cache) GetBytesValue

func (c *Cache) GetBytesValue(key string) ([]byte, error)

GetBytesValue Get bytes data from cache by given key. Return data bytes and any error raised.

func (*Cache) GetCounter

func (c *Cache) GetCounter(key string) (int64, error)

GetCounter Get int val from cache by given key.Count cache and data cache are in two independent namespace. Return int data value and any error raised.

func (*Cache) IncrCounter

func (c *Cache) IncrCounter(key string, increment int64, ttl time.Duration) (int64, error)

IncrCounter Increase int val in cache by given key.Count cache and data cache are in two independent namespace. Return int data value and any error raised.

func (*Cache) MGetBytesValue

func (c *Cache) MGetBytesValue(keys ...string) (map[string][]byte, error)

MGetBytesValue get multiple bytes data from cache by given keys. Return data bytes map and any error if raised.

func (*Cache) MSetBytesValue

func (c *Cache) MSetBytesValue(data map[string][]byte, ttl time.Duration) error

MSetBytesValue set multiple bytes data to cache with given key-value map. Return any error if raised.

func (*Cache) SetBytesValue

func (c *Cache) SetBytesValue(key string, bytes []byte, ttl time.Duration) error

SetBytesValue Set bytes data to cache by given key. Return any error raised.

func (*Cache) SetCounter

func (c *Cache) SetCounter(key string, v int64, ttl time.Duration) error

SetCounter Set int val in cache by given key.Count cache and data cache are in two independent namespace. Return any error raised.

func (*Cache) SetGCErrHandler

func (c *Cache) SetGCErrHandler(f func(err error))

SetGCErrHandler Set callback to handler error raised when gc.

func (*Cache) UpdateBytesValue

func (c *Cache) UpdateBytesValue(key string, bytes []byte, ttl time.Duration) error

UpdateBytesValue Update bytes data to cache by given key only if the cache exist. Return any error raised.

type Config

type Config struct {
	redispool.Config
	GCPeriod int64 //Period of gc.Default value is 30 second.
	GCLimit  int64 //Max delete limit in every gc call.Default value is 100.
}

Config Cache driver config.

func (*Config) Create

func (c *Config) Create() (cache.Driver, error)

Create create new cache driver. Return driver created and any error if raised.

Jump to

Keyboard shortcuts

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