fixed_time_cache

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2022 License: MIT Imports: 3 Imported by: 1

README

A very simple key/value container with fixed expire time.

Use linked list to avoid full scan while cleaning.

Use fixed expire time to ensure O(1) insertion.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	ExtendOnGet bool

	ClearCooldown time.Duration
	// contains filtered or unexported fields
}

func NewCache

func NewCache(defaultExpiration time.Duration, extendOnGet bool, clearcooldown time.Duration) *Cache

func (*Cache) ClearExpired

func (c *Cache) ClearExpired()

func (*Cache) Get

func (c *Cache) Get(key interface{}, ExtendOnGet bool) (val interface{}, ok bool)

func (*Cache) Load

func (c *Cache) Load(key interface{}) (val interface{}, ok bool)

func (*Cache) Set

func (c *Cache) Set(key interface{}, val interface{})

func (*Cache) Store

func (c *Cache) Store(key interface{}, val interface{})

type Item

type Item struct {
	Object     interface{}
	Expiration time.Time
}

Jump to

Keyboard shortcuts

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