cache

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: Apache-2.0 Imports: 3 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 {
	*gcache.Cache
	// contains filtered or unexported fields
}

func New

func New() (*Cache, error)

func (*Cache) Add

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

Add will error if adding a key that already exists in cache

func (*Cache) Contains

func (c *Cache) Contains(key string) bool

func (*Cache) Get

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

func (*Cache) Remove

func (c *Cache) Remove(key string) bool

func (*Cache) Set

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

Set will add OR overwrite an element in the cache

type ICache

type ICache interface {
	Add(key string, value interface{}, ttl ...time.Duration) error
	Set(key string, value interface{}, ttl ...time.Duration)
	Get(key string) (value interface{}, ok bool)
	Contains(key string) (exists bool)
	Remove(key string) bool
}

Jump to

Keyboard shortcuts

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