common

package
v0.0.0-...-104d43a Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	WriteBuffer         = 64
	BlockBuffer         = 64
	Expired     float64 = 24
)

Functions

func FileIsNotExist

func FileIsNotExist(path string) bool

func GetPid

func GetPid(file string) (string, error)

func HashCode

func HashCode(in string) int32

取hash值

func HashPath

func HashPath(path string) string

func HashString

func HashString(in string) string

取hash值,换成串

func InitLog

func InitLog(logConfig, logFile string)

func PrintErr

func PrintErr()

func SavePid

func SavePid(file string) error

Types

type Config

type Config struct {
	//ip
	Host string
	Port int
	//data path
	VarPath string
	//log path
	LogPath string
	//is master db
	IsMaster bool
	//connect timeout,0 is none
	Timeout int
	//The num of expiration time
	ExpiredNum int
	// The expiration type
	//0 none 1 hour 2 day
	ExpiredType int
	//Write buffer in Mbs,default is 64mb
	WriteBuffer int
	//Block buffer in Mbs,default is 64mb
	BlockBuffer  int
	AllowManager bool
	HttpHost     string
	HttpPort     int
}

config

func (*Config) Load

func (c *Config) Load(f *ini.File)

load config and set default value

func (*Config) ToString

func (c *Config) ToString() string

config value to string

type GetProcessor

type GetProcessor interface {
	GetProcessor(name string) (Processor, error)
}

type NetLayout

type NetLayout interface {
	Start(pm GetProcessor, host string, port int, timeout int) error
	Stop() error
}

type Processor

type Processor interface {
	// Parameters:
	//  - Key
	Get(key []byte) (r []byte, err error)
	// Parameters:
	//  - Key
	//  - Value
	Set(key []byte, value []byte) (err error)
	// Parameters:
	//  - Key
	Exists(key []byte) (r bool, err error)
	// Parameters:
	//  - Key
	Delete(key []byte) (err error)
	// Parameters:
	//  - Keys
	//  - Values
	BatchSet(keys [][]byte, values [][]byte) (err error)
	QGet() (r []byte, err error)
	// Parameters:
	//  - Value
	QSet(value []byte) (err error)
	// Parameters:
	//  - Value
	BatchQSet(value [][]byte) (err error)
	// Parameters:
	//  - Size
	BatchQGet(size int) (r [][]byte, err error)
	// Parameters:
	//  - KeyStart
	//  - KeyEnd
	//  - Limit
	Scan(key_start []byte, key_end []byte, limit int) (ks [][]byte, vs [][]byte, err error)
}

Jump to

Keyboard shortcuts

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