cache

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

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

Go to latest
Published: Mar 3, 2014 License: GPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

System:Period:[数据类型ID]=数据时间粒度 [时间]:[数据类型ID]:[网元ID]=该网元指标 System:Relation:[ID]=该节点下属所有子节点ID的数组

针对不同的数据类型,采用不同的缓存方式 1、普通不过期缓存,使用Set和Get方法统计处理,三段式Key值 2、定时过期数据,按StoreMinute进行存贮,过期清理

Index

Constants

View Source
const (
	PoolSize = 4
)

Variables

View Source
var (
	//	lock        sync.RWMutex
	TimeChanged func(*common.TimeMessage)
)

Functions

func AddRowsToCache

func AddRowsToCache(nodeName string, rows *common.DataRows)

增加一条记录

func CloseCache

func CloseCache()

func CountCache

func CountCache() int

func FormatKey

func FormatKey(inKeyType string, inkeyValue interface{}, outKeyName string) string

按固定格式连接关键字,组成key

func FormatStoreKey

func FormatStoreKey(inKeyType string, inkeyValue interface{}) string

外面用key

func Get

func Get(key string) (interface{}, bool)

get key value

func GetDataRow

func GetDataRow(dataKey string, timeKey string, id string) (*common.DataRow, bool)

取缓存的数据行,如果在内部缓存中没有就到外部缓存找。前提是时间已过期

func Init

func Init(cfg *config.Config, rcfg *config.RelationConfig)

初始化缓存

func RedisStatus

func RedisStatus()

func Set

func Set(key string, value interface{})

Types

type IdAvailable

type IdAvailable struct {
	Id          string
	IsAvailable bool
}

id是否可用

type RedisClient

type RedisClient struct {
	Redis redis.Client
	Id    string
}

func GetClient

func GetClient(key string) (*RedisClient, error)

创建一个连接

func (*RedisClient) Close

func (this *RedisClient) Close()

type TimeCache

type TimeCache struct {
	Id      string
	KeyName string //数据列字段名
	// contains filtered or unexported fields
}

func NewTimeCache

func NewTimeCache(id string, keyName string) *TimeCache

创建一个新的缓存实例

func (*TimeCache) Add

func (this *TimeCache) Add(rows *common.DataRows)

增加一条数据

func (*TimeCache) Clean

func (this *TimeCache) Clean(s time.Duration)

清理过期数据

func (*TimeCache) Close

func (this *TimeCache) Close()

close it

func (*TimeCache) ExistsTime

func (this *TimeCache) ExistsTime(timeKey string) bool

func (*TimeCache) Get

func (this *TimeCache) Get(timeKey string, id string) (interface{}, bool)

func (*TimeCache) Run

func (this *TimeCache) Run()

运行计算

func (*TimeCache) Start

func (this *TimeCache) Start()

启动实例

type TimeCacheItem

type TimeCacheItem struct {
	Cache       map[string]interface{}
	ExpiredTime time.Time
}

Jump to

Keyboard shortcuts

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