rediscache

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: MIT Imports: 12 Imported by: 0

README

Redis Cache package

This package provides data storage in the key value format in the radis database

To run the redisDB docker image, use

build/redis_up.sh

Usage:

import "github.com/rurick/rediscache"
rediscahe.SetCacheExpiration(2 * time.Minute)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(key string) error

Delete - delete value from cache by key

func GetInt64

func GetInt64(key string) (int64, bool, error)

GetInt64 - get value from cache as int64

func GetString

func GetString(key string) (string, bool, error)

GetString - get value from cache as string

func KeyGen

func KeyGen(v ...interface{}) string

KeyGen generate 20bits hex key for v

func Load

func Load(key string, obj interface{}) (exists bool, err error)

Load object from cache to obj

func Set

func Set(key string, val interface{}, opt ...Opt) error

Set - set value in cache cache life time by default is cacheExpiration for set up cache life time for setting value set up opt parameter (exp: Opt{"expiration", time.Minute})

func SetCacheExpiration

func SetCacheExpiration(d time.Duration)

SetCacheExpiration - set default cache expire time

Types

type Opt

type Opt struct {
	Name string
	Val  interface{}
}

Jump to

Keyboard shortcuts

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