Documentation
¶
Index ¶
- Constants
- type CacheInstance
- type GoCacheClient
- func (cc *GoCacheClient) CloseConnect() error
- func (cc *GoCacheClient) Del(ctx context.Context, key string) error
- func (cc *GoCacheClient) DelBulk(ctx context.Context, key string) error
- func (cc *GoCacheClient) Get(ctx context.Context, key string) (interface{}, bool)
- func (cc *GoCacheClient) Set(ctx context.Context, key string, value interface{}, ttl time.Duration) error
- type RedisInstance
- func (i *RedisInstance) CloseConnect() error
- func (i *RedisInstance) Del(ctx context.Context, key string) error
- func (i *RedisInstance) DelBulk(ctx context.Context, key string) error
- func (i *RedisInstance) Get(ctx context.Context, key string) (interface{}, bool)
- func (i *RedisInstance) Set(ctx context.Context, key string, value interface{}, expired time.Duration) error
Constants ¶
View Source
const ( // NumInstance is number of instance. NumInstance = 5 // DefaultExpiration is default expiration. DefaultExpiration = 60 // PurgeExpiredTime is time to purge cache. PurgeExpiredTime = 10 )
View Source
const ( // RedisMaxRetry is max retry count. RedisMaxRetry = 3 // RedisConnectionRandmax is using generate connection key. RedisConnectionRandmax = 10000 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheInstance ¶
type CacheInstance interface {
Set(ctx context.Context, key string, value interface{}, expired time.Duration) error
Get(ctx context.Context, key string) (interface{}, bool)
Del(ctx context.Context, key string) error
DelBulk(ctx context.Context, key string) error
CloseConnect() error
}
CacheInstance interface.
type GoCacheClient ¶
type GoCacheClient struct{}
GoCacheClient struct.
func NewGoCacheClient ¶
func NewGoCacheClient() *GoCacheClient
NewGoCacheClient creates a new GoCacheClient.
func (*GoCacheClient) CloseConnect ¶
func (cc *GoCacheClient) CloseConnect() error
CloseConnect close connection.
func (*GoCacheClient) Del ¶
func (cc *GoCacheClient) Del(ctx context.Context, key string) error
Del deletes from cache.
func (*GoCacheClient) DelBulk ¶
func (cc *GoCacheClient) DelBulk(ctx context.Context, key string) error
DelBulk bulk deletes from cache.
type RedisInstance ¶
type RedisInstance struct {
ConnectionPersistent bool
// contains filtered or unexported fields
}
RedisInstance struct.
func NewRedis ¶
func NewRedis(connectionpersistent bool, redisdb int) *RedisInstance
NewRedis creates a new RedisInstance.
func (*RedisInstance) CloseConnect ¶
func (i *RedisInstance) CloseConnect() error
CloseConnect close connection.
func (*RedisInstance) Del ¶
func (i *RedisInstance) Del(ctx context.Context, key string) error
Del deletes from cache.
func (*RedisInstance) DelBulk ¶
func (i *RedisInstance) DelBulk(ctx context.Context, key string) error
DelBulk bulk deletes from cache.
Click to show internal directories.
Click to hide internal directories.