xormrediscache

package module
v0.0.0-...-859b313 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2018 License: BSD-3-Clause Imports: 9 Imported by: 1

README

xorm-redis-cache

XORM Redis Cache

Go Walker

Documentation

Index

Constants

View Source
const (
	DEFAULT_EXPIRATION = time.Duration(0)
	FOREVER_EXPIRATION = time.Duration(-1)

	LOGGING_PREFIX = "[redis_cacher]"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type RedisCacher

type RedisCacher struct {
	Logger core.ILogger
	// contains filtered or unexported fields
}

Wraps the Redis client to meet the Cache interface.

func MakeRedisCacher

func MakeRedisCacher(pool *redis.Pool, defaultExpiration time.Duration, logger core.ILogger) *RedisCacher

MakeRedisCacher build a cacher based on redis.Pool

func NewRedisCacher

func NewRedisCacher(host string, password string, defaultExpiration time.Duration, logger core.ILogger) *RedisCacher

New a Redis Cacher, host as IP endpoint, i.e., localhost:6379, provide empty string or nil if Redis server doesn't require AUTH command, defaultExpiration sets the expire duration for a key to live. Until redigo supports sharding/clustering, only one host will be in hostList

engine.SetDefaultCacher(xormrediscache.NewRedisCacher("localhost:6379", "", xormrediscache.DEFAULT_EXPIRATION, engine.Logger))

or set MapCacher

engine.MapCacher(&user, xormrediscache.NewRedisCacher("localhost:6379", "", xormrediscache.DEFAULT_EXPIRATION, engine.Logger))

func (*RedisCacher) ClearBeans

func (c *RedisCacher) ClearBeans(tableName string)

func (*RedisCacher) ClearIds

func (c *RedisCacher) ClearIds(tableName string)

func (*RedisCacher) DelBean

func (c *RedisCacher) DelBean(tableName string, id string)

func (*RedisCacher) DelIds

func (c *RedisCacher) DelIds(tableName, sql string)

func (*RedisCacher) Flush

func (c *RedisCacher) Flush() error

Delete all xorm cached objects

func (*RedisCacher) GetBean

func (c *RedisCacher) GetBean(tableName string, id string) interface{}

func (*RedisCacher) GetIds

func (c *RedisCacher) GetIds(tableName, sql string) interface{}

func (*RedisCacher) GetPool

func (c *RedisCacher) GetPool() (*redis.Pool, error)

func (*RedisCacher) PutBean

func (c *RedisCacher) PutBean(tableName string, id string, obj interface{})

func (*RedisCacher) PutIds

func (c *RedisCacher) PutIds(tableName, sql string, ids interface{})

func (*RedisCacher) SetPool

func (c *RedisCacher) SetPool(pool *redis.Pool)

Jump to

Keyboard shortcuts

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