gmcache

package
v0.0.0-...-0cd0da9 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2017 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EXPIRED_ERROR error = errors.New("Expire error")
View Source
var KEY_NOT_EXIST_ERROR error = errors.New("Key not exist error")
View Source
var OUT_OF_MEMORY_LIMIT_ERROR error = errors.New("Out of memory limit error")

Functions

func InitLog

func InitLog() error

func Main

func Main()

Types

type IRpcServer

type IRpcServer interface {
	Run() error
	Stop() error
}

func NewRpcServer

func NewRpcServer(addr string, storage IStorage) IRpcServer

type IStorage

type IStorage interface {
	Set(key string, value []byte, ttl time.Duration) error
	Get(key string) (*KVItem, error)
	Delete(key string) error
}

type KVItem

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

type RpcServer

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

func (*RpcServer) Delete

func (this *RpcServer) Delete(ctx context.Context, arg *proto.DelOptArg) (*proto.DelOptRet, error)

func (*RpcServer) Get

func (this *RpcServer) Get(ctx context.Context, arg *proto.GetOptArg) (*proto.GetOptRet, error)

func (*RpcServer) Run

func (this *RpcServer) Run() error

func (*RpcServer) Set

func (this *RpcServer) Set(ctx context.Context, arg *proto.SetOptArg) (*proto.SetOptRet, error)

func (*RpcServer) Stop

func (this *RpcServer) Stop() (err error)

type Storage

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

func NewStorage

func NewStorage(memChangedChan chan int64) *Storage

func (*Storage) Delete

func (this *Storage) Delete(key string) error

func (*Storage) DeleteExpiredKeyRandom

func (this *Storage) DeleteExpiredKeyRandom() int64

func (*Storage) Get

func (this *Storage) Get(key string) (*KVItem, error)

func (*Storage) Set

func (this *Storage) Set(key string, value []byte, ttl time.Duration) error

type StorageManager

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

The implementation of IStorage

func NewStorageManager

func NewStorageManager(bucketNum int, memoryLimit int64, cleanInterval time.Duration) *StorageManager

memoryLimit unit is in byte

func (*StorageManager) Delete

func (this *StorageManager) Delete(key string) error

func (*StorageManager) Get

func (this *StorageManager) Get(key string) (*KVItem, error)

func (*StorageManager) Run

func (this *StorageManager) Run()

func (*StorageManager) Set

func (this *StorageManager) Set(key string, value []byte, ttl time.Duration) error

func (*StorageManager) Stop

func (this *StorageManager) Stop()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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