engine

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine interface {
	Get(key string) (int, error)
	Increment(key string, delta, min, max int) (bool, error)
	IncrementTo(key string, delta, min, max, incr int) (bool, error)
}

func NewEngineByMemory

func NewEngineByMemory() Engine

func NewEngineByRedis

func NewEngineByRedis(opt RedisOption) Engine

type MemData

type MemData struct {
	Counter  int
	LastTime time.Time
}

type Memory

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

func (*Memory) Get

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

func (*Memory) Increment

func (m *Memory) Increment(key string, delta, min, max int) (bool, error)

func (*Memory) IncrementTo

func (m *Memory) IncrementTo(key string, delta, min, max, incr int) (bool, error)

type Redis

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

func (*Redis) Get

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

func (*Redis) Increment

func (r *Redis) Increment(key string, delta, min, max int) (bool, error)

func (*Redis) IncrementTo

func (r *Redis) IncrementTo(key string, delta, min, max, incr int) (bool, error)

type RedisOption added in v0.0.3

type RedisOption struct {
	Client *redis.Client
	Expire int
}

Jump to

Keyboard shortcuts

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