cache

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: CC0-1.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Get(key string) (string, error)
	Set(key string, value string, durationInMinutes int) error
	Del(key string) error
	Ping() error
}

type CacheEntry added in v0.1.0

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

CacheEntry is a value stored in the cache.

type Config

type Config struct {
	Host     string `json:"host"`
	Port     int    `json:"port"`
	Password string `json:"password"`
	DB       int    `json:"db"`
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig() *Config

func (*Config) GetConfig

func (c *Config) GetConfig() map[string]interface{}

func (*Config) Load

func (c *Config) Load(file string) error

type Memory added in v0.1.0

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

Memory is a thread-safe cache.

func NewMemory added in v0.1.0

func NewMemory() *Memory

func (*Memory) CleanUp added in v0.1.0

func (sc *Memory) CleanUp()

CleanUp periodically removes expired entries from the cache.

func (*Memory) Del added in v0.1.1

func (sc *Memory) Del(key string) error

Delete removes a value from the cache.

func (*Memory) Get added in v0.1.0

func (sc *Memory) Get(key string) (string, error)

Get retrieves a value from the cache. If the value is not found or has expired, it returns false.

func (*Memory) Ping added in v0.1.2

func (sc *Memory) Ping() error

Ping checks if the cache is available.

func (*Memory) Set added in v0.1.0

func (sc *Memory) Set(key string, value string, durationInMinutes int) error

Set stores a value in the cache with a given TTL (time to live) in seconds.

type Redis

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

func NewRedis

func NewRedis(file string) *Redis

func (*Redis) Del

func (r *Redis) Del(key string) error

func (*Redis) Get

func (r *Redis) Get(key string) (string, error)

func (*Redis) Ping

func (r *Redis) Ping() error

func (*Redis) Set

func (r *Redis) Set(key string, value string, durationInMinutes int) error

Jump to

Keyboard shortcuts

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