redis_cache

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCache

func NewCache(ctx context.Context, redisClient *redis.Client) repository.CacheInterface

NewCache creates a new TTLCache instance connected to a Redis server.

Types

type TTLCache

type TTLCache struct {
	// contains filtered or unexported fields
}

TTLCache is a Redis-based cache with time-to-live (TTL) expiration.

func (*TTLCache) Get

func (c *TTLCache) Get(key string) ([]byte, bool)

Get retrieves the value associated with the given key from the Redis cache.

func (*TTLCache) GetTTL

func (c *TTLCache) GetTTL(key string) (time.Duration, bool)

GetTTL returns the remaining time before the specified key expires.

func (*TTLCache) Pop

func (c *TTLCache) Pop(key string) ([]byte, bool)

Pop removes and returns the item with the specified key from the Redis cache.

func (*TTLCache) Remove

func (c *TTLCache) Remove(key string)

Remove removes the item with the specified key from the Redis cache.

func (*TTLCache) RemoveByPrefix

func (c *TTLCache) RemoveByPrefix(prefix string)

RemoveByPrefix removes all items with the specified prefix from the Redis cache.

func (*TTLCache) Set

func (c *TTLCache) Set(key string, value []byte, ttl time.Duration)

Set adds a new item to the Redis cache with the specified key, value, and TTL.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL