excache

package
v0.0.0-...-d6e4ce5 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache represents safe for concurrent use passive expiring cache. Passively expires old records. Uses heap.Interface under the hood.

func New

func New(capacity int) (*Cache, error)

New returns an initialized cache instance

func (*Cache) Clear

func (c *Cache) Clear()

Clear removes all saved records

func (*Cache) Delete

func (c *Cache) Delete(key string)

Delete removes the record associated with the specified key from the cache

func (*Cache) Expire

func (c *Cache) Expire()

Expire removes old records

func (*Cache) Get

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

Get returns (value, true) or (nil, false) for a given key. Resets TTL.

func (*Cache) Len

func (c *Cache) Len() int

Len returns the number of records in the cache

func (*Cache) Put

func (c *Cache) Put(key string, value interface{}, ttl time.Duration)

Put inserts new record into the cache

Jump to

Keyboard shortcuts

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