Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { DriverName() string ExistKey(ctx context.Context, key string) (exist bool, err error) GetExpiredTime(ctx context.Context, key string) (exist bool, expiredAt time.Time, err error) Load(ctx context.Context, key string) (exist bool, value string, err error) LoadWithEX(ctx context.Context, key string) (loaded bool, expiredTime time.Duration, value string, err error) LoadJson(ctx context.Context, key string, receiverPtr any) (exist bool, err error) LoadJsonWithEX(ctx context.Context, key string, receiverPtr any) (exist bool, expiredTime time.Duration, err error) Store(ctx context.Context, key string, value string) (err error) StoreEX(ctx context.Context, key string, value string, expiration time.Duration) (err error) StoreJson(ctx context.Context, key string, senderPtr any) (err error) StoreJsonEX(ctx context.Context, key string, senderPtr any, expiration time.Duration) (err error) Delete(ctx context.Context, key string) (err error) LoadAndDelete(ctx context.Context, key string) (loaded bool, value string, err error) LoadAndDeleteJson(ctx context.Context, key string, receivePtr any) (loaded bool, err error) LoadOrStore(ctx context.Context, key string, storeValue string) (loaded bool, value string, err error) LoadOrStoreEX(ctx context.Context, key string, storeValue string, expiration time.Duration) (loaded bool, value string, err error) LoadOrStoreJson(ctx context.Context, key string, senderPtr any, receiverPtr any) (loaded bool, err error) LoadOrStoreJsonEX(ctx context.Context, key string, senderPtr any, receiverPtr any, expiration time.Duration) (loaded bool, err error) IsMember(ctx context.Context, key string, member string) (isMember bool, err error) IsMembers(ctx context.Context, key string, members ...string) (isMembers bool, err error) AddMember(ctx context.Context, key string, member string) (err error) AddMembers(ctx context.Context, key string, members ...string) (err error) RemoveMember(ctx context.Context, key string, member string) (err error) GetMembers(ctx context.Context, key string) (members []string, err error) GetRandomMember(ctx context.Context, key string) (member string, err error) GetRandomMembers(ctx context.Context, key string, count int64) (members []string, err error) HGetValue(ctx context.Context, key string, field string) (exist bool, value string, err error) HGetValues(ctx context.Context, key string, fields ...string) (resultMap map[string]string, err error) HGetJson(ctx context.Context, key string, field string, receiverPtr any) (exist bool, err error) HGetAll(ctx context.Context, key string) (resultMap map[string]string, err error) HGetAllJson(ctx context.Context, key string, receiverPtr any) (err error) HSetValue(ctx context.Context, key string, field string, value string) (err error) HSetValues(ctx context.Context, key string, values map[string]string) (err error) HRemoveValue(ctx context.Context, key string, field string) (err error) HRemoveValues(ctx context.Context, key string, fields ...string) (err error) Expire(ctx context.Context, key string, expire time.Duration) (err error) }
type Counter ¶
type Counter interface { // Increase 将计数器的值增加delta,如果key不存在,则创建一个新的计数器,初始值为delta Increase(ctx context.Context, key string, delta uint64) (result CounterResultEnum) // IncreaseWithExpireWhenNotExist 将计数器的值增加delta;如果key不存在,则创建一个新的计数器,初始值为delta,过期时间为expire IncreaseWithExpireWhenNotExist(ctx context.Context, key string, delta uint64, expire time.Duration) (result CounterResultEnum) // SetExpire 设置计数器的过期时间,如果key已存在,则会将过期时间重置为expire SetExpire(ctx context.Context, key string, expire time.Duration) (result CounterResultEnum) // SetExpireWhenNotSet 将一个未设置过期时间的计数器的过期时间设置为expire;如果key不存在或已设置过期时间,则不会生效 SetExpireWhenNotSet(ctx context.Context, key string, expire time.Duration) (result CounterResultEnum) // ExpireImmediately 计数器立即过期,如果key不存在,则不会生效 ExpireImmediately(ctx context.Context, key string) (result CounterResultEnum) }
type CounterResultEnum ¶ added in v1.2.8
type CounterResultEnum int
const ( CounterResultEnumFailed CounterResultEnum = -1 // 操作失败 CounterResultEnumNotEffective CounterResultEnum = 0 // 操作未改变任何内容 CounterResultEnumSuccess CounterResultEnum = 1 // 操作成功 )
func (CounterResultEnum) GetValue ¶ added in v1.2.8
func (e CounterResultEnum) GetValue() int
Click to show internal directories.
Click to hide internal directories.