cachepoolutil

package module
v0.0.0-...-58e84c7 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SequenceGet

func SequenceGet() string

* * 取时间显示式的流水号 * @return 返回形式举例:20200521094216048001

Types

type CacheInfo

type CacheInfo struct {
	Id         string      `json:"Id"`         //编号,作为关键字存在
	Data       interface{} `json:"Data"`       //缓存的数据对象
	CreateDate time.Time   `json:"CreateDate"` //创建时间
	LastDate   time.Time   `json:"LastDate"`   //最后访问时间
}

用于定义缓存信息的类

func New

func New(Id string, Data interface{}) *CacheInfo

*

  • 新建缓存信息结构体
  • @param Id 编号,作为关键字存在
  • @param Data 缓存的数据对象
  • @return 返回新创建的结构体

type CachePool

type CachePool struct{}

自定义缓存池

func (CachePool) Add

func (cp CachePool) Add(cacheInfo *CacheInfo) (bool, string, interface{})

* * 添加缓存 * @param cacheInfo * @return

func (CachePool) AddData

func (cp CachePool) AddData(Id string, data interface{}) (bool, string, interface{})

* * 添加缓存 * @param Id * @param oData * @return

func (CachePool) Clear

func (cp CachePool) Clear() (bool, string, interface{})

*

  • 清理缓存
  • @return

func (CachePool) Contains

func (cp CachePool) Contains(Id string) bool

* * 判断是否包含缓存,包含返回true * @param Id * @return

func (CachePool) Find

func (cp CachePool) Find(Id string) *CacheInfo

* * 查找缓存信息 * @param Id * @return

func (CachePool) FindData

func (cp CachePool) FindData(Id string) interface{}

* * 查找缓存对象 * @param Id * @return

func (CachePool) Free

func (cp CachePool) Free(Id string) (bool, string, interface{})

* * 释放缓存 * @param Id * @return

func (CachePool) FreeByData

func (cp CachePool) FreeByData(data interface{}) (bool, string, interface{})

* * 释放缓存 * @param Id * @return

func (CachePool) FreeById

func (cp CachePool) FreeById(Id string) (bool, string, interface{})

* * 释放缓存 * @param Id * @return

func (CachePool) FreeByTime

func (cp CachePool) FreeByTime(iMinute int) (bool, string, interface{})

* * 释放指定分钟之前的缓存 * @param iMinute * @return

type CacheTxtUtil

type CacheTxtUtil struct{}

func (CacheTxtUtil) CreateCacheFile

func (ctu CacheTxtUtil) CreateCacheFile(object interface{}, sCacheFile string) (bool, string, interface{})

*

  • 创建缓存文件
  • @param object 待存储数据对象
  • @param sCacheFile 缓存文件路径及文件名
  • @return

func (CacheTxtUtil) CreateCacheFileByList

func (ctu CacheTxtUtil) CreateCacheFileByList(list []interface{}, sCacheFile string) (bool, string, interface{})

*

  • 创建缓存文件
  • @param list 数据集合
  • @param sCacheFile 缓存文件路径及文件名
  • @return

func (CacheTxtUtil) DelCacheFile

func (ctu CacheTxtUtil) DelCacheFile(sCacheFile string) (bool, string, interface{})

*

  • 删除缓存文件
  • @param sCacheFile

func (CacheTxtUtil) ReadCacheFile

func (ctu CacheTxtUtil) ReadCacheFile(sCacheFile ...string) []interface{}

*

  • 读取缓存文件
  • @param sCacheFile 缓存文件路径及文件名
  • @return

Source Files

  • CacheInfo.go
  • CachePool.go
  • CacheTxtUtil.go
  • SequenceUtil.go

Jump to

Keyboard shortcuts

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