rsmemory

package module
v0.0.0-...-7083799 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SYNC_CHANNEL_NAME       string = "RedisMultilevelCache_Sync"
	READ_FROM_MEMORY        string = "READ_FROM_MEMORY"
	READ_FROM_REDIS         string = "READ_FROM_REDIS"
	OUTDATE_READ_FROM_REDIS string = "OUTDATE_READ_FROM_REDIS"
	READ_DEFAULT            string = "READ_DEFAULT"

	DEFAULT_REDIS_URI string = "localhost:6379"
)
View Source
const (
	HASH_SLOT_COUNT = 16384 //Inspired by Redis cluster hash slot implementation
)

Variables

This section is empty.

Functions

func GetRunDir

func GetRunDir() (string, error)

Types

type Cache

type Cache struct {
	HashSlot  uint16
	TimeStamp int64
	Value     interface{}
}

type Configrsmemory

type Configrsmemory struct {
	RedisURL          string
	HashSlot          uint16
	SYNC_CHANNEL_NAME string
}

type HashSlotCalculator

type HashSlotCalculator interface {
	CalculateHashSlot(key string) uint16
	// contains filtered or unexported methods
}

func NewHashSlotCalculator

func NewHashSlotCalculator(slot uint16) HashSlotCalculator

type InProcessCache

type InProcessCache interface {
	Get(key string) *Cache
	Set(key string, data *Cache)
	Size() int
	// contains filtered or unexported methods
}

func NewInProcessCache

func NewInProcessCache() InProcessCache

init new memory cache

type LastUpdatedDictionary

type LastUpdatedDictionary interface {
	Get(key uint16) int64
	Set(key uint16, data int64)
	// contains filtered or unexported methods
}

func NewLastUpdatedDictionary

func NewLastUpdatedDictionary() LastUpdatedDictionary

type NewInput

type NewInput struct {
	RedisURL string
}

new input for constructor

type RedisMultilevelCache

type RedisMultilevelCache interface {
	Get(key string) (interface{}, string)
	Set(key string, data interface{})
	GetRedisService() *Service
	Size() int
	// contains filtered or unexported methods
}

func NewRedisMultilevelCache

func NewRedisMultilevelCache(config *Configrsmemory) RedisMultilevelCache

type Service

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

service redis

func New

func New(input *NewInput) *Service

new return service

func (*Service) Do

func (s *Service) Do(comman string, args ...interface{}) (reply interface{}, err error)

func (*Service) Get

func (s *Service) Get(key string) (reply string, err error)

func (*Service) GetCacheFromRedis

func (s *Service) GetCacheFromRedis(key string) (data Cache, err error)

func (*Service) Publish

func (s *Service) Publish(key string, value string) error

Publish publish key value

func (*Service) SaveCacheToRedis

func (s *Service) SaveCacheToRedis(key string, data Cache)

func (*Service) ScriptEvaluate

func (s *Service) ScriptEvaluate(luaScript string, num_args int, args ...interface{}) (reply interface{}, err error)

var luaScript = @"

local result={}
result[1] = redis.call('GET', KEYS[1])
result[2] = redis.call('TTL', KEYS[1])
return result;

";

func (*Service) Set

func (s *Service) Set(key string, value string) (reply interface{}, err error)

func (*Service) Subscribe

func (s *Service) Subscribe(key string, msg chan []byte) error

Subscribe subscribe

Jump to

Keyboard shortcuts

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