cache

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	String() string
	SetPrefix(string)
	Connect() error
	Get(key string) (string, error)
	Set(key string, val interface{}, expire int) error
	Del(key string) error
	HashGet(hk, key string) (string, error)
	HashDel(hk, key string) error
	Increase(key string) error
	Decrease(key string) error
	Expire(key string, dur time.Duration) error
	AdapterQueue
	AdapterLocker
}

type AdapterLocker

type AdapterLocker interface {
	Lock(key string, ttl int64, options *redislock.Options) (*redislock.Lock, error)
}

type AdapterQueue

type AdapterQueue interface {
	Append(message Message) error
	Register(name string, f ConsumerFunc)
	Run()
	Shutdown()
}

type ConsumerFunc

type ConsumerFunc func(Message) error

type Memory

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

func (*Memory) Append

func (m *Memory) Append(message Message) error

func (*Memory) Connect

func (m *Memory) Connect() error

func (*Memory) Decrease

func (m *Memory) Decrease(key string) error

func (*Memory) Del

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

func (*Memory) Expire

func (m *Memory) Expire(key string, dur time.Duration) error

func (*Memory) Get

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

func (*Memory) HashDel

func (m *Memory) HashDel(hk, key string) error

func (*Memory) HashGet

func (m *Memory) HashGet(hk, key string) (string, error)

func (*Memory) Increase

func (m *Memory) Increase(key string) error

func (*Memory) Lock

func (m *Memory) Lock(_ string, _ int64, _ *redislock.Options) (*redislock.Lock, error)

Lock 不支持memory的lock

func (*Memory) Register

func (m *Memory) Register(name string, f ConsumerFunc)

func (*Memory) Run

func (m *Memory) Run()

func (*Memory) Set

func (m *Memory) Set(key string, val interface{}, expire int) error

func (*Memory) SetPrefix

func (r *Memory) SetPrefix(string)

func (*Memory) Shutdown

func (m *Memory) Shutdown()

func (*Memory) String

func (*Memory) String() string

type MemoryMessage

type MemoryMessage struct {
	redisqueue.Message
}

func (*MemoryMessage) GetID

func (m *MemoryMessage) GetID() string

func (*MemoryMessage) GetPrefix

func (m *MemoryMessage) GetPrefix() (prefix string)

func (*MemoryMessage) GetStream

func (m *MemoryMessage) GetStream() string

func (*MemoryMessage) GetValues

func (m *MemoryMessage) GetValues() map[string]interface{}

func (*MemoryMessage) SetID

func (m *MemoryMessage) SetID(id string)

func (*MemoryMessage) SetPrefix

func (m *MemoryMessage) SetPrefix(prefix string)

func (*MemoryMessage) SetStream

func (m *MemoryMessage) SetStream(stream string)

func (*MemoryMessage) SetValues

func (m *MemoryMessage) SetValues(values map[string]interface{})

type Message

type Message interface {
	SetID(string)
	SetStream(string)
	SetValues(map[string]interface{})
	GetID() string
	GetStream() string
	GetValues() map[string]interface{}
	GetPrefix() string
	SetPrefix(string)
}

type Redis

type Redis struct {
	ConnectOption   *redis.Options
	ConsumerOptions *redisqueue.ConsumerOptions
	ProducerOptions *redisqueue.ProducerOptions
	// contains filtered or unexported fields
}

Redis cache implement

func (*Redis) Append

func (r *Redis) Append(message Message) error

func (*Redis) Connect

func (r *Redis) Connect() error

Connect Setup

func (*Redis) Decrease

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

func (*Redis) Del

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

Del delete key in redis

func (*Redis) Expire

func (r *Redis) Expire(key string, dur time.Duration) error

Set ttl

func (*Redis) Get

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

Get from key

func (*Redis) GetClient

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

GetClient 暴露原生client

func (*Redis) HashDel

func (r *Redis) HashDel(hk, key string) error

HashDel delete key in specify redis's hashtable

func (*Redis) HashGet

func (r *Redis) HashGet(hk, key string) (string, error)

HashGet from key

func (*Redis) Increase

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

Increase

func (*Redis) Lock

func (r *Redis) Lock(key string, ttl int64, options *redislock.Options) (*redislock.Lock, error)

func (*Redis) Register

func (r *Redis) Register(name string, f ConsumerFunc)

func (*Redis) Run

func (r *Redis) Run()

func (*Redis) Set

func (r *Redis) Set(key string, val interface{}, expire int) error

Set value with key and expire time

func (*Redis) SetPrefix

func (r *Redis) SetPrefix(string)

func (*Redis) Shutdown

func (r *Redis) Shutdown()

func (*Redis) String

func (*Redis) String() string

type RedisMessage

type RedisMessage struct {
	redisqueue.Message
}

func (*RedisMessage) GetID

func (m *RedisMessage) GetID() string

func (*RedisMessage) GetPrefix

func (m *RedisMessage) GetPrefix() (prefix string)

func (*RedisMessage) GetStream

func (m *RedisMessage) GetStream() string

func (*RedisMessage) GetValues

func (m *RedisMessage) GetValues() map[string]interface{}

func (*RedisMessage) SetID

func (m *RedisMessage) SetID(id string)

func (*RedisMessage) SetPrefix

func (m *RedisMessage) SetPrefix(prefix string)

func (*RedisMessage) SetStream

func (m *RedisMessage) SetStream(stream string)

func (*RedisMessage) SetValues

func (m *RedisMessage) SetValues(values map[string]interface{})

Jump to

Keyboard shortcuts

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