v2

package module
v2.0.0-...-c0075a2 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: MIT Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCache

func NewCache[K comparable, V any]() v2.Cache[K, V]

NewCache returns a new cache with the given types

func NewFilesCache

func NewFilesCache[K comparable, V any](dir string) v2.Cache[K, V]

NewFilesCache returns cache instance for local file system storage

func NewRedisCache

func NewRedisCache[K comparable, V any](config RedisCacheConfig) v2.Cache[K, V]

NewRedisCache returns a new redis cache interface with redis instance configured

Types

type Cache

type Cache[K comparable, V any] struct {
	// contains filtered or unexported fields
}

Cache is implemented by third-party packages which provide from github.com/Code-Hex/go-generics-cache

func (Cache[K, V]) Delete

func (c Cache[K, V]) Delete(key K)

func (Cache[K, V]) Get

func (c Cache[K, V]) Get(key K) (value V, ok bool)

func (Cache[K, V]) Set

func (c Cache[K, V]) Set(key K, val V)

func (Cache[K, V]) SetWithExp

func (c Cache[K, V]) SetWithExp(key K, val V, exp time.Duration)

type FilesCache

type FilesCache[K comparable, V any] struct {
}

func (*FilesCache[K, V]) Delete

func (f *FilesCache[K, V]) Delete(key K)

func (*FilesCache[K, V]) Get

func (f *FilesCache[K, V]) Get(key K) (value V, ok bool)

func (*FilesCache[K, V]) Set

func (f *FilesCache[K, V]) Set(key K, val V)

func (*FilesCache[K, V]) SetWithExp

func (f *FilesCache[K, V]) SetWithExp(key K, val V, exp time.Duration)

type RedisCache

type RedisCache[K comparable, V any] struct {
}

RedisCache is a redis cache wrapper which implemented the cache interface

func (*RedisCache[K, V]) Delete

func (r *RedisCache[K, V]) Delete(key K)

func (*RedisCache[K, V]) Get

func (r *RedisCache[K, V]) Get(key K) (value V, ok bool)

func (*RedisCache[K, V]) Set

func (r *RedisCache[K, V]) Set(key K, val V)

func (*RedisCache[K, V]) SetWithExp

func (r *RedisCache[K, V]) SetWithExp(key K, val V, exp time.Duration)

type RedisCacheConfig

type RedisCacheConfig struct {
	Addr     string `yaml:"addr"`
	UserName string `yaml:"user_name"`
	Password string `yaml:"password"`
	Database uint   `yaml:"database"`
}

Jump to

Keyboard shortcuts

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