Documentation
¶
Index ¶
- func NewRedisClientWithConfig(config *redis.Options, logger *zap.Logger) (*redis.Client, error)
- type Cache
- type MemoryCache
- func (c *MemoryCache) Clear(ctx context.Context) error
- func (c *MemoryCache) Delete(ctx context.Context, key string) error
- func (c *MemoryCache) Get(ctx context.Context, key string, dest interface{}) (bool, error)
- func (c *MemoryCache) Ping(ctx context.Context) error
- func (c *MemoryCache) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) error
- type NoOpCache
- func (c *NoOpCache) Clear(ctx context.Context) error
- func (c *NoOpCache) Delete(ctx context.Context, key string) error
- func (c *NoOpCache) Get(ctx context.Context, key string, dest interface{}) (bool, error)
- func (c *NoOpCache) Ping(ctx context.Context) error
- func (c *NoOpCache) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) error
- type RedisCache
- func (c *RedisCache) Clear(ctx context.Context) error
- func (c *RedisCache) ClearPattern(ctx context.Context, pattern string) error
- func (c *RedisCache) Delete(ctx context.Context, key string) error
- func (c *RedisCache) Get(ctx context.Context, key string, dest interface{}) (bool, error)
- func (c *RedisCache) Ping(ctx context.Context) error
- func (c *RedisCache) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache interface { // Set armazena um valor no cache com tempo de expiração Set(ctx context.Context, key string, value interface{}, expiration time.Duration) error // Get recupera um valor do cache Get(ctx context.Context, key string, dest interface{}) (bool, error) // Delete remove um valor do cache Delete(ctx context.Context, key string) error // Clear remove todos os valores do cache Clear(ctx context.Context) error // Ping verifica se o cache está acessível Ping(ctx context.Context) error }
Cache define a interface para operações de cache
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache implementa a interface Cache usando armazenamento em memória
func NewMemoryCache ¶
func NewMemoryCache(defaultExpiration, cleanupInterval time.Duration, metrics *metrics.APIMetrics, logger *zap.Logger) *MemoryCache
NewMemoryCache cria uma nova instância de MemoryCache
func (*MemoryCache) Clear ¶
func (c *MemoryCache) Clear(ctx context.Context) error
Clear remove todos os valores do cache
func (*MemoryCache) Delete ¶
func (c *MemoryCache) Delete(ctx context.Context, key string) error
Delete remove um valor do cache
type NoOpCache ¶
type NoOpCache struct{}
NoOpCache é uma implementação de Cache que não faz nada Usada quando o cache está desabilitado na configuração
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
RedisCache implementa a interface Cache usando Redis
func NewRedisCache ¶
NewRedisCache cria uma nova instância de RedisCache
func (*RedisCache) Clear ¶
func (c *RedisCache) Clear(ctx context.Context) error
Clear remove todos os valores do cache
func (*RedisCache) ClearPattern ¶
func (c *RedisCache) ClearPattern(ctx context.Context, pattern string) error
ClearPattern remove valores do cache por padrão
func (*RedisCache) Delete ¶
func (c *RedisCache) Delete(ctx context.Context, key string) error
Delete remove um valor do cache
Click to show internal directories.
Click to hide internal directories.