cache

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package cache provides Redis cache abstraction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Get(ctx context.Context, key string, dest any) error
	Set(ctx context.Context, key string, value any, expiration time.Duration) error
	Delete(ctx context.Context, key string) error
	Exists(ctx context.Context, key string) (bool, error)
}

Cache provides a simple cache interface.

type RedisCache

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

RedisCache implements Cache using Redis.

func NewRedisCache

func NewRedisCache(client *redis.Client, prefix string) *RedisCache

NewRedisCache creates a new Redis cache.

func (*RedisCache) Delete

func (c *RedisCache) Delete(ctx context.Context, key string) error

Delete removes a value from cache.

func (*RedisCache) Exists

func (c *RedisCache) Exists(ctx context.Context, key string) (bool, error)

Exists checks if a key exists in cache.

func (*RedisCache) Get

func (c *RedisCache) Get(ctx context.Context, key string, dest any) error

Get retrieves a value from cache.

func (*RedisCache) Set

func (c *RedisCache) Set(ctx context.Context, key string, value any, expiration time.Duration) error

Set stores a value in cache.

Jump to

Keyboard shortcuts

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