cache

package
v1.28.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HomepageCacheKey is used to cache the rendered homepage
	HomepageCacheKey = "homepage-cache"
	// NavigationCacheKey is used to cache the navigation bar data
	NavigationCacheKey = "navigation-cache"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HomepageCache

type HomepageCache struct {
	*dpcache.Cache
}

HomepageCache is a wrapper to dpcache.Cache which has additional fields and methods specifically for caching homepage data

func NewHomepageCache

func NewHomepageCache(ctx context.Context, updateInterval *time.Duration) (*HomepageCache, error)

NewHomepageCache create a homepage cache object to be used in the service which will update at every updateInterval If updateInterval is nil, this means that the cache will only be updated once at the start of the service

func (*HomepageCache) AddUpdateFunc

func (hc *HomepageCache) AddUpdateFunc(key string, updateFunc func() (*model.HomepageData, error))

AddUpdateFunc adds an update function to the homepage cache

type NavigationCache struct {
	*dpcache.Cache
}

NavigationCache is a wrapper to dpcache.Cache which has additional fields and methods specifically for caching navigation data

func NewNavigationCache

func NewNavigationCache(ctx context.Context, updateInterval *time.Duration) (*NavigationCache, error)

NewNavigationCache create a navigation cache object to be used in the service which will update at every updateInterval If updateInterval is nil, this means that the cache will only be updated once at the start of the service

func (nc *NavigationCache) AddUpdateFunc(key string, updateFunc func() *models.Navigation)

AddUpdateFunc adds an update function to the homepage cache

Jump to

Keyboard shortcuts

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