Documentation ¶
Overview ¶
* @Date: 2023-07-20 09:46:36 * @LastEditTime: 2023-07-20 09:46:37 * @Description:
* @Date: 2023-07-20 09:46:36 * @LastEditTime: 2023-07-20 09:47:05 * @Description:
Index ¶
- func FromExpiration(ctx context.Context) (time.Duration, bool)
- func FromKey(ctx context.Context) (string, bool)
- func FromTag(ctx context.Context) (string, bool)
- func NewExpiration(ctx context.Context, ttl time.Duration) context.Context
- func NewKey(ctx context.Context, key string) context.Context
- func NewTag(ctx context.Context, key string) context.Context
- type Cache
- func (p *Cache) Initialize(tx *gorm.DB) error
- func (p *Cache) MemberTagKey(ctx context.Context, tag string, key string) (bool, error)
- func (p *Cache) Name() string
- func (p *Cache) Query(tx *gorm.DB)
- func (p *Cache) QueryCache(ctx context.Context, key string, dest any) error
- func (p *Cache) QueryDB(tx *gorm.DB)
- func (p *Cache) RemoveFromKey(ctx context.Context, key string) error
- func (p *Cache) RemoveFromTag(ctx context.Context, tag string) error
- func (p *Cache) RemoveTagCache(ctx context.Context, tag string, key string) error
- func (p *Cache) SaveCache(ctx context.Context, key string, dest any, ttl time.Duration) error
- func (p *Cache) SaveTagCache(ctx context.Context, tag string, key string) error
- type Config
- type DefaultJSONSerializer
- type Serializer
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromExpiration ¶
FromExpiration @param ctx @date 2022-07-02 08:11:40
func NewExpiration ¶
NewExpiration @param ctx @param ttl @date 2022-07-02 08:11:41
Types ¶
type Cache ¶
type Cache struct { // Serializer 序列化 Serializer Serializer // contains filtered or unexported fields }
func (*Cache) Initialize ¶
Initialize @param tx @date 2022-07-02 08:09:47
func (*Cache) MemberTagKey ¶
MemberTagKey 是否缓存数据
func (*Cache) QueryCache ¶
QueryCache 查询缓存数据 @param ctx @param key @param dest
func (*Cache) RemoveFromKey ¶
RemoveFromTag 根据key删除缓存数据 @param ctx @param key @date 2022-07-02 08:08:59
func (*Cache) RemoveFromTag ¶
RemoveFromTag 根据tag删除缓存数据 @param ctx @param tag @date 2022-07-02 08:08:59
func (*Cache) RemoveTagCache ¶
RemoveTagCache 删除缓存数据
type Config ¶
type Config struct { Store Store Prefix string Serializer Serializer }
type DefaultJSONSerializer ¶
type DefaultJSONSerializer struct{}
func (*DefaultJSONSerializer) Deserialize ¶
func (d *DefaultJSONSerializer) Deserialize(data []byte, v any) error
Deserialize @param data @param v @date 2022-07-02 08:12:25
type Serializer ¶
type Store ¶
type Store interface { // Set 写入缓存数据 Set(ctx context.Context, key string, value any, ttl time.Duration) error // Get 获取缓存数据 Get(ctx context.Context, key string) ([]byte, error) // SaveTagKey 将缓存key写入tag SaveTagKey(ctx context.Context, tag, key string) error // RemoveTagKey 将缓存key从tag中删除 RemoveTagKey(ctx context.Context, tag, key string) error // MemberTagKey 判断key在tag中 MemberTagKey(ctx context.Context, tag, key string) (bool, error) // RemoveFromTag 根据缓存tag删除缓存 RemoveFromTag(ctx context.Context, tag string) error // RemoveFromKey 根据缓存key删除缓存 RemoveFromKey(ctx context.Context, key string) error }
Click to show internal directories.
Click to hide internal directories.