Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OptTraceTCOperation ¶ added in v2.0.7
func OptTraceTCOperation(operation string) func(*tenantCache)
OptTraceTCOperation is an option to set an operation name for tracing in TenantCache. It overrides a default value as long as the given operation name is not empty.
Types ¶
type MasterCache ¶ added in v2.0.3
type MasterCache interface { KeyExists(c context.Context, key string) (bool, error) Keys(c context.Context, pattern string) ([]string, error) TTL(c context.Context, key string) (time.Duration, error) SetString(c context.Context, key string, data string, ttl time.Duration) error GetString(c context.Context, key string) (string, error) SetJSON(c context.Context, key string, data interface{}, ttl time.Duration) error GetJSON(c context.Context, key string, dst interface{}) (bool, error) MSetJSON(c context.Context, keys []string, data []interface{}, ttl time.Duration) error MGetJSON(c context.Context, dst interface{}, keys ...string) error MGet(c context.Context, keys ...string) ([]interface{}, error) HSet(c context.Context, key string, args ...interface{}) error HGet(c context.Context, key string, field string) (string, error) HMGet(c context.Context, key string, fields ...string) ([]interface{}, error) HGetAll(c context.Context, key string) (map[string]string, error) HGets(c context.Context, keysWithFields map[string]string) (map[string]string, error) RPush(c context.Context, key string, valueList []string) error LRange(c context.Context, key string, start, stop int64) ([]string, error) SAdd(c context.Context, key string, elements interface{}) error SRem(c context.Context, key string, elements interface{}) error SMembers(c context.Context, key string) ([]string, error) SRandMemberN(c context.Context, key string, count int64) ([]string, error) SIsMember(c context.Context, key string, element interface{}) (bool, error) IncrementValue(c context.Context, key string) error DelKey(c context.Context, keys ...string) error Expire(c context.Context, key string, ttl time.Duration) error Pipeline() redis.Pipeliner Pipelined(c context.Context, fn func(redis.Pipeliner) error) ([]redis.Cmder, error) Eval(c context.Context, script string, keys []string, args ...interface{}) (interface{}, error) EvalSha(c context.Context, sha1 string, keys []string, args ...interface{}) (interface{}, error) Run(c context.Context, script *redis.Script, keys []string, args ...interface{}) (interface{}, error) }
MasterCache provides functions for master redis db.
func NewMasterCache ¶ added in v2.0.3
func NewMasterCache(master *dbdrivers.RedisDBConn, prefix string, opts ...MasterCacheOption) MasterCache
NewMasterCache creates a new MasterCache. This assumes it is called after the (*Bean).InitDB() func and takes (bean.DBDeps).MasterRedisDB as input.
type MasterCacheOption ¶ added in v2.0.7
type MasterCacheOption func(*masterCache)
func OptTraceMCOperation ¶ added in v2.0.7
func OptTraceMCOperation(operation string) MasterCacheOption
OptTraceMCOperation is an option to set an operation name for tracing in MasterCache. It overrides a default value as long as the given operation name is not empty.
type TenantCache ¶ added in v2.0.3
type TenantCache interface { KeyExists(c context.Context, tenantID uint64, key string) (bool, error) Keys(c context.Context, tenantID uint64, pattern string) ([]string, error) TTL(c context.Context, tenantID uint64, key string) (time.Duration, error) SetString(c context.Context, tenantID uint64, key string, data string, ttl time.Duration) error GetString(c context.Context, tenantID uint64, key string) (string, error) SetJSON(c context.Context, tenantID uint64, key string, data interface{}, ttl time.Duration) error GetJSON(c context.Context, tenantID uint64, key string, dst interface{}) (bool, error) MSetJSON(c context.Context, tenantID uint64, keys []string, data []interface{}, ttl time.Duration) error MGetJSON(c context.Context, tenantID uint64, dst interface{}, keys ...string) error MGet(c context.Context, tenantID uint64, keys ...string) ([]interface{}, error) HSet(c context.Context, tenantID uint64, key string, args ...interface{}) error HGet(c context.Context, tenantID uint64, key string, field string) (string, error) HMGet(c context.Context, tenantID uint64, key string, fields ...string) ([]interface{}, error) HGetAll(c context.Context, tenantID uint64, key string) (map[string]string, error) HGets(c context.Context, tenantID uint64, keysWithFields map[string]string) (map[string]string, error) RPush(c context.Context, tenantID uint64, key string, valueList []string) error LRange(c context.Context, tenantID uint64, key string, start, stop int64) ([]string, error) SAdd(c context.Context, tenantID uint64, key string, elements interface{}) error SRem(c context.Context, tenantID uint64, key string, elements interface{}) error SMembers(c context.Context, tenantID uint64, key string) ([]string, error) SRandMemberN(c context.Context, tenantID uint64, key string, count int64) ([]string, error) SIsMember(c context.Context, tenantID uint64, key string, element interface{}) (bool, error) IncrementValue(c context.Context, tenantID uint64, key string) error DelKey(c context.Context, tenantID uint64, keys ...string) error Expire(c context.Context, tenantID uint64, key string, ttl time.Duration) error Pipeline(tenantID uint64) redis.Pipeliner Pipelined(c context.Context, tenantID uint64, fn func(redis.Pipeliner) error) ([]redis.Cmder, error) Eval(c context.Context, tenantID uint64, script string, keys []string, args ...interface{}) (interface{}, error) EvalSha(c context.Context, tenantID uint64, sha1 string, keys []string, args ...interface{}) (interface{}, error) Run(c context.Context, tenantID uint64, script *redis.Script, keys []string, args ...interface{}) (interface{}, error) }
TenantCache provides functions for tenant redis dbs You pass in tenantID to connect to the corresponding redis db.
func NewTenantCache ¶ added in v2.0.3
func NewTenantCache(tenants map[uint64]*dbdrivers.RedisDBConn, prefix string, opts ...TenantCacheOption) TenantCache
NewTenantCache creates a new TenantCache if you enable tenant mode (`detabase.tenant.on` in config). This assumes it is called after the (*Bean).InitDB() func and takes (bean.DBDeps).TenantRedisDBs as input.
type TenantCacheOption ¶ added in v2.0.7
type TenantCacheOption func(*tenantCache)