runtime

package
v0.0.0-...-2e696e2 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultGCInterval means gc interval.
	DefaultGCInterval       = 60 * time.Second // 1 minute
	ZeroInt64         int64 = 0
)

Functions

This section is empty.

Types

type RuntimeCache

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

RuntimeCache is runtime cache adapter. it contains a RW locker for safe map storage.

func NewRuntimeCache

func NewRuntimeCache() *RuntimeCache

NewRuntimeCache returns a new *RuntimeCache.

func (*RuntimeCache) ClearAll

func (ca *RuntimeCache) ClearAll() error

ClearAll will delete all item in runtime cache.

func (*RuntimeCache) Decr

func (ca *RuntimeCache) Decr(key string) (int64, error)

Decr decrease counter in runtime cache.

func (*RuntimeCache) Delete

func (ca *RuntimeCache) Delete(key string) error

Delete item in runtime cacha. if not exists, we think it's success

func (*RuntimeCache) Exists

func (ca *RuntimeCache) Exists(key string) (bool, error)

Exist check item exist in runtime cache.

func (*RuntimeCache) Get

func (ca *RuntimeCache) Get(key string) (interface{}, error)

Get cache from runtime cache. if non-existed or expired, return nil.

func (*RuntimeCache) GetInt

func (ca *RuntimeCache) GetInt(key string) (int, error)

returns value int format by given key if non-existed or expired, return 0.

func (*RuntimeCache) GetInt64

func (ca *RuntimeCache) GetInt64(key string) (int64, error)

returns value int64 format by given key if non-existed or expired, return 0.

func (*RuntimeCache) GetString

func (ca *RuntimeCache) GetString(key string) (string, error)

returns value string format by given key if non-existed or expired, return "".

func (*RuntimeCache) Incr

func (ca *RuntimeCache) Incr(key string) (int64, error)

Incr increase int64 counter in runtime cache.

func (*RuntimeCache) Set

func (ca *RuntimeCache) Set(key string, value interface{}, ttl int64) error

Set cache to runtime. ttl is second, if ttl is 0, it will be forever till restart.

type RuntimeItem

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

RuntimeItem store runtime cache item.

Jump to

Keyboard shortcuts

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