proc

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoExpiration time.Duration = -1 //No expiration mark

)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func NewCache

func NewCache(defaultExpiration, gcInterval time.Duration) (c *Cache)

create a new cache system

func (*Cache) Add

func (c *Cache) Add(k string, v interface{}, d time.Duration) error

add new operations, if data item exists, then error

func (*Cache) Count

func (c *Cache) Count() int

number of data items in the return cache

func (*Cache) Delete

func (c *Cache) Delete(k string)

operate deletion

func (*Cache) DeleteExpired

func (c *Cache) DeleteExpired()

delete expired cache

func (*Cache) Flush

func (c *Cache) Flush()

clear the cache

func (*Cache) Get

func (c *Cache) Get(k string) (interface{}, bool)

Get cache

func (*Cache) Load

func (c *Cache) Load(r io.Reader) error

load from io.Reader

func (*Cache) LoadFromFile

func (c *Cache) LoadFromFile(filename string) error

load from file

func (*Cache) Replace

func (c *Cache) Replace(k string, v interface{}, d time.Duration) error

replace

func (*Cache) Save

func (c *Cache) Save(w io.Writer) (err error)

input cache data to io.Writer

func (*Cache) SaveToFile

func (c *Cache) SaveToFile(filename string) error

serialize to file

func (*Cache) Set

func (c *Cache) Set(k string, v interface{}, d time.Duration, isSlide bool)

set the data item of cache, overwrite it if it is set, isSlide expired or not when d expires

func (*Cache) StopGc

func (c *Cache) StopGc()

stop gc

type Item

type Item struct {
	Object     interface{}   //data item
	Expiration int64         //expiration time of data item (0 never expires)
	IsSlide    bool          // slide out of date or not
	Dur        time.Duration //duration
}

func (Item) IsExpired

func (item Item) IsExpired() bool

Jump to

Keyboard shortcuts

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