polycache

package module
v0.0.0-...-33569f7 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2024 License: MIT Imports: 3 Imported by: 0

README

PolyCache Go

Cache abstraction layer for Go which supports NATS KV, ValKey and BigCache.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IPolyCache

type IPolyCache interface {
	Set(ctx context.Context, key string, data any, expiry time.Duration) error
	Get(ctx context.Context, key string, data any) error
	Delete(ctx context.Context, key string) error
}

type Item

type Item struct {
	Data       any       `json:"value"`
	Expiration time.Time `json:"expiration"`
}

func NewItem

func NewItem(data any) *Item

func (*Item) IsExpired

func (i *Item) IsExpired() bool

func (*Item) ParseData

func (i *Item) ParseData(data any) error

func (*Item) SetExpiration

func (i *Item) SetExpiration(expiration time.Duration)

type PolyCache

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

func NewCache

func NewCache(provider IPolyCache) *PolyCache

func (*PolyCache) Delete

func (p *PolyCache) Delete(ctx context.Context, key string) error

func (*PolyCache) Get

func (p *PolyCache) Get(ctx context.Context, key string, data any) error

func (*PolyCache) Set

func (p *PolyCache) Set(ctx context.Context, key string, data any, expiry time.Duration) error

Directories

Path Synopsis
backend

Jump to

Keyboard shortcuts

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