omnicache

package module
v0.0.0-...-ecd902a Latest Latest
Warning

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

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

README

OmniCache

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 IOmniCache

type IOmniCache 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 OmniCache

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

func NewCache

func NewCache(provider IOmniCache) *OmniCache

func (*OmniCache) Delete

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

func (*OmniCache) Get

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

func (*OmniCache) Set

func (p *OmniCache) 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