cache

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: Apache-2.0 Imports: 7 Imported by: 2

README

go-generics-cache

A generics cache library for Go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewSimpleCache

func NewSimpleCache[K comparable, V any](size int, interval time.Duration) *Cache[K, V]

func (*Cache[K, V]) Close

func (c *Cache[K, V]) Close() (err error)

func (*Cache[K, V]) Delete

func (c *Cache[K, V]) Delete(ctx context.Context, key K) (err error)

func (*Cache[K, V]) DeleteExpired

func (c *Cache[K, V]) DeleteExpired(ctx context.Context)

func (*Cache[K, V]) Get

func (c *Cache[K, V]) Get(ctx context.Context, key K) (v V, err error)

func (*Cache[K, V]) Keys

func (c *Cache[K, V]) Keys() []K

func (*Cache[K, V]) Set

func (c *Cache[K, V]) Set(ctx context.Context, key K, value V, opts ...ItemOption) (err error)

func (*Cache[K, V]) SetNX added in v0.0.5

func (c *Cache[K, V]) SetNX(ctx context.Context, key K, value V, opts ...ItemOption) (b bool, err error)

type Item

type Item[V any] struct {
	// contains filtered or unexported fields
}

func (*Item[V]) Expired

func (i *Item[V]) Expired() bool

type ItemOption

type ItemOption func(*itemOptions)

func WithExpiration

func WithExpiration(exp time.Duration) ItemOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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