redis

package
v0.74.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package redis contains the concrete implementation of a cache that supports TTL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache encapsulates a Redis-based caching mechanism.

func New

func New(opt *redis.Options, useCase string) (*Cache, error)

New creates a cache returns a new Redis client that will be used as the cache store.

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, key string) (interface{}, bool, error)

Get executes a lookup and returns whether a key exists in the cache along with its value.

func (*Cache) Purge

func (c *Cache) Purge(ctx context.Context) error

Purge evicts all keys present in the cache.

func (*Cache) Remove

func (c *Cache) Remove(ctx context.Context, key string) error

Remove evicts a specific key from the cache.

func (*Cache) Set

func (c *Cache) Set(ctx context.Context, key string, value interface{}) error

Set registers a key-value pair to the cache.

func (*Cache) SetTTL

func (c *Cache) SetTTL(ctx context.Context, key string, value interface{}, ttl time.Duration) error

SetTTL registers a key-value pair to the cache, specifying an expiry time.

Jump to

Keyboard shortcuts

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