cachettl

package
v0.0.0-...-8084858 Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheOption

type CacheOption func(c *InMemoryCache)

CacheOption provides configuration options for the in memory cache.

func WithSecondsBetweenCleanUps

func WithSecondsBetweenCleanUps(seconds uint) CacheOption

WithSecondsBetweenCleanUps configuration option for seconds between clean ups.

func WithTTL

func WithTTL(seconds uint) CacheOption

WithTTL configuration option for time to live key values.

type DTO

type DTO struct {
	Key         int64
	DomainModel DomainModel // cannot be nil
	Data        []byte
}

DTO as data transfer object brings together the application layers and the cache.

func NewDTO

func NewDTO(domain DomainModel, data []byte) *DTO

type DomainModel

type DomainModel string

DomainModel as per DDD.

type InMemoryCache

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

InMemoryCache contains cached domain model data.

func NewCache

func NewCache(ctx context.Context, domain DomainModel, config ...CacheOption) *InMemoryCache

NewCache is constructor for in memory cache.

func (*InMemoryCache) Close

func (c *InMemoryCache) Close()

func (*InMemoryCache) Delete

func (c *InMemoryCache) Delete(key int64) error

func (*InMemoryCache) Get

func (c *InMemoryCache) Get(key int64) (*DTO, error)

Get returns a DTO if it finds one for the passed key. defer not used due to the performance penalty

func (*InMemoryCache) Set

func (c *InMemoryCache) Set(dto *DTO) error

Jump to

Keyboard shortcuts

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