Documentation ¶
Index ¶
- Variables
- func NewLockClient(cache *Cache) *redislock.Client
- type Cache
- func (c *Cache) Client() *redis.Client
- func (c *Cache) Close() error
- func (c *Cache) Delete(pCtx context.Context, key string) error
- func (c *Cache) Get(pCtx context.Context, key string) ([]byte, error)
- func (c *Cache) GetTime(ctx context.Context, key string) (time.Time, error)
- func (c *Cache) MSetWithTTL(ctx context.Context, keyValues map[string]any, expiration time.Duration) error
- func (c *Cache) Prefix() string
- func (c *Cache) Scripter() redis.Scripter
- func (c *Cache) Set(pCtx context.Context, key string, value []byte, expiration time.Duration) error
- func (c *Cache) SetNX(pCtx context.Context, key string, value []byte, expiration time.Duration) (bool, error)
- func (c *Cache) SetTime(ctx context.Context, key string, value time.Time, expiration time.Duration, ...) error
- type CacheConfig
- type ErrKeyNotFound
- type LazyCache
Constants ¶
This section is empty.
Variables ¶
var ( NotificationLockCache = CacheConfig{/* contains filtered or unexported fields */} EmailRateLimitersCache = CacheConfig{/* contains filtered or unexported fields */} PushNotificationRateLimitersCache = CacheConfig{/* contains filtered or unexported fields */} OneTimeLoginCache = CacheConfig{/* contains filtered or unexported fields */} AuthTokenForceRefreshCache = CacheConfig{/* contains filtered or unexported fields */} CommunitiesCache = CacheConfig{/* contains filtered or unexported fields */} IndexerServerThrottleCache = CacheConfig{/* contains filtered or unexported fields */} RefreshNFTsThrottleCache = CacheConfig{/* contains filtered or unexported fields */} TokenProcessingThrottleCache = CacheConfig{/* contains filtered or unexported fields */} TokenProcessingMetadataCache = CacheConfig{/* contains filtered or unexported fields */} EmailThrottleCache = CacheConfig{/* contains filtered or unexported fields */} GraphQLAPQCache = CacheConfig{/* contains filtered or unexported fields */} FeedCache = CacheConfig{/* contains filtered or unexported fields */} SocialCache = CacheConfig{/* contains filtered or unexported fields */} SearchCache = CacheConfig{/* contains filtered or unexported fields */} UserPrefCache = CacheConfig{/* contains filtered or unexported fields */} TokenManageCache = CacheConfig{/* contains filtered or unexported fields */} WalletsBloomFilterCache = CacheConfig{/* contains filtered or unexported fields */} MintCache = CacheConfig{/* contains filtered or unexported fields */} )
Functions ¶
func NewLockClient ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache represents an abstraction over a redis client
func (*Cache) MSetWithTTL ¶
func (c *Cache) MSetWithTTL(ctx context.Context, keyValues map[string]any, expiration time.Duration) error
MSetWithTTL sets multiple keys in the redis cache via pipelining.
func (*Cache) Scripter ¶
func (c *Cache) Scripter() redis.Scripter
Scripter returns an implementation of the redis.Scripter interface using this Cache
func (*Cache) SetNX ¶
func (c *Cache) SetNX(pCtx context.Context, key string, value []byte, expiration time.Duration) (bool, error)
SetNX sets a value in the redis cache if it doesn't already exist. Returns true if the key did not already exist and was set, false if the key did exist and therefore was not set.
func (*Cache) SetTime ¶
func (c *Cache) SetTime(ctx context.Context, key string, value time.Time, expiration time.Duration, onlyIfLater bool) error
SetTime sets a time in the redis cache. If onlyIfLater is true, the value will only be set if the key doesn't exist, or if the existing key's value is an earlier time than the one being set.
type CacheConfig ¶
type CacheConfig struct {
// contains filtered or unexported fields
}
type ErrKeyNotFound ¶
type ErrKeyNotFound struct {
Key string
}
func (ErrKeyNotFound) Error ¶
func (e ErrKeyNotFound) Error() string
type LazyCache ¶
type LazyCache struct { Cache *Cache CalcFunc func(context.Context) ([]byte, error) Key string TTL time.Duration }
LazyCache implements a lazy loading cache that stores data only when it is requested
func (LazyCache) Load ¶
Load queries the cache for the given key, and if it is current returns the data. It's possible for Load to return stale data, however the staleness of data can be limited by configuring a shorter TTL. The tradeoff being that a shorter TTL results in more cache misses which can have a noticeable delay in getting data.