cache

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEdgesNotFound = errors.New("edges not found in cache")
)
View Source
var (
	ErrEntityNotFound = fmt.Errorf("entity not found in cache")
)
View Source
var (
	ErrFieldsNotFound = errors.New("fields not found in cache")
)

Functions

func NewEdgeCache

func NewEdgeCache(ttl time.Duration)

func NewEntityCache

func NewEntityCache(ttl time.Duration)

func NewFieldCache

func NewFieldCache(ttl time.Duration)

Types

type Cache

type Cache[K comparable, V any] struct {
	Values map[K]Item[V]
	// contains filtered or unexported fields
}
var Edge Cache[string, []entity.Edge]
var Field Cache[string, []entity.Field]

func NewCache

func NewCache[K comparable, V any](ttl time.Duration) Cache[K, V]

func (*Cache[K, V]) Delete

func (c *Cache[K, V]) Delete(key K)

func (*Cache[K, V]) Get

func (c *Cache[K, V]) Get(key K) (V, bool)

func (*Cache[K, V]) GetAll

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

func (*Cache[K, V]) Set

func (c *Cache[K, V]) Set(key K, val V)

type EntityCache

type EntityCache struct {
	Cache[string, entity.Entity]
}
var Entity EntityCache

func (*EntityCache) GetByUniqueInput

func (c *EntityCache) GetByUniqueInput(where entity.EntityWhereUniqueInput) (entity.Entity, bool)

type Item

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

Jump to

Keyboard shortcuts

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