cache

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: Unlicense Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	REDIS_ON   bool   `env:"REDIS_ON" envDefault:"false" json:"redis_on"`
	REDIS_HOST string `env:"REDIS_HOST" envDefault:"localhost" json:"redis_host"`
	REDIS_PORT string `env:"REDIS_PORT" envDefault:"6379" json:"redis_port"`
	REDIS_PASS string `env:"REDIS_PASS" envDefault:"" json:"redis_pass"`
}

func (*Config) Parse

func (this *Config) Parse() (err error)

type InMemory added in v1.0.1

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

InMemory is an implementation of the cache interface which stores values in-memory.

func NewInMemory added in v1.0.1

func NewInMemory() *InMemory

NewInMemory creates a new InMemory instance with default values.

func (*InMemory) Count added in v1.0.1

func (c *InMemory) Count() int

Count total data.

func (*InMemory) Del added in v1.0.1

func (c *InMemory) Del(key string) error

Del delete data.

func (*InMemory) Flush added in v1.0.1

func (c *InMemory) Flush()

Flush clear all data in cache.

func (*InMemory) Get added in v1.0.1

func (c *InMemory) Get(key string) (interface{}, error)

Get retrieves a value from the InMemory cache implementation.

func (*InMemory) Items added in v1.0.1

func (c *InMemory) Items() map[string]cache.Item

Items get all data.

func (*InMemory) Set added in v1.0.1

func (c *InMemory) Set(key string, value interface{}) error

Set sets a value for a key in the InMemory cache implementation.

func (*InMemory) WithExpiration added in v1.0.1

func (c *InMemory) WithExpiration(d time.Duration) *InMemory

WithExpiration updates the expiration value of `c`.

type Redis

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

func (*Redis) Client added in v1.0.2

func (r *Redis) Client() *redis.Client

func (*Redis) Del

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

func (*Redis) Flush added in v1.0.2

func (r *Redis) Flush() (err error)

func (*Redis) Get

func (r *Redis) Get(key string, data interface{}) (err error)

func (*Redis) Init

func (r *Redis) Init() (err error)

func (*Redis) Set

func (r *Redis) Set(key string, data_ interface{}, ttl time.Duration) (err error)

Jump to

Keyboard shortcuts

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