container

package
v0.0.0-...-2403d1f Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CTRedis  = "Redis"
	CTMemory = "Memory"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container interface {
	Get(key string) (string, error)
	Set(key string, val string, expire int64) error //expire: secend
	Delete(key string) error
	IsExist(key string) bool
	Count() (int64, error)
}

func NewContainer

func NewContainer(containerType, cfg string) (Container, error)

type ContainerErr

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

func (ContainerErr) Error

func (e ContainerErr) Error() string

type ErrorType

type ErrorType int
const (
	KeyNotFound ErrorType = iota
)

type MemContainer

type MemContainer struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*MemContainer) Count

func (mr *MemContainer) Count() (int64, error)

func (*MemContainer) Delete

func (mr *MemContainer) Delete(key string) error

func (*MemContainer) Get

func (mr *MemContainer) Get(key string) (string, error)

Get ....

func (*MemContainer) IsExist

func (mr *MemContainer) IsExist(key string) bool

func (*MemContainer) Set

func (mr *MemContainer) Set(key string, val string, expire int64) error

type RedisContainer

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

func (*RedisContainer) ClearAll

func (rc *RedisContainer) ClearAll() error

ClearAll clean all cache in redis. delete this redis collection.

func (*RedisContainer) Count

func (rc *RedisContainer) Count() (int64, error)

Count ...

func (*RedisContainer) Delete

func (rc *RedisContainer) Delete(key string) error

Delete cache in redis.

func (*RedisContainer) Eof

func (rc *RedisContainer) Eof() bool

func (*RedisContainer) Get

func (rc *RedisContainer) Get(key string) (string, error)

Get 。。。

func (*RedisContainer) IsExist

func (rc *RedisContainer) IsExist(key string) bool

IsExist check cache's existence in redis.

func (*RedisContainer) ScanNext

func (rc *RedisContainer) ScanNext() ([]string, error)

ScanNext ...

func (*RedisContainer) Set

func (rc *RedisContainer) Set(key string, val string, expire int64) error

//Append 。。。

func (rc *RedisContainer) Append(key, val string) error {
	if _, err := rc.do("SADD", key, val); err != nil {
		return err
	}
	if _, err := rc.do("HSET", rc.name, key, true); err != nil {
		return err
	}
	return nil
}

Set ...

func (*RedisContainer) StartScan

func (rc *RedisContainer) StartScan()

StartScan 。。。

Jump to

Keyboard shortcuts

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