nscache

package
v0.11.9 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NotificationNamespaceChanges = "notifications.changes.namespace"
)

Constants for notification topics.

Variables

This section is empty.

Functions

This section is empty.

Types

type NamespacedCache

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

A NamespacedCache is used to cache namespaced information. The cache will invalidate all items when their namespace is deleted or updated.

func New

func New(pubsub bahamut.PubSubClient, maxSize int64, options ...Option) *NamespacedCache

New returns a new namespace cache.

func (*NamespacedCache) Delete

func (c *NamespacedCache) Delete(namespace string, key string) bool

Delete attempts to delete an item from the cache using the given namespace and key.

func (*NamespacedCache) Get

func (c *NamespacedCache) Get(namespace string, key string) *ccache.Item

Get returns the cached item for the provided namespaced key.

func (*NamespacedCache) Set

func (c *NamespacedCache) Set(namespace string, key string, value any, duration time.Duration)

Set sets a new namespaced key with the given value, with given expiration. namespace must be set. key is optional. It can be empty if you wish to only associate one value to one namespace.

func (*NamespacedCache) Start

func (c *NamespacedCache) Start(ctx context.Context)

Start starts listening to notifications for automatic invalidation

type Option

type Option func(*config)

Option represents a parametric option for the nscache.

func OptionNotificationName

func OptionNotificationName(name string) Option

OptionNotificationName allows to change the notification name used to listen to namespace changes from the pubsub. This defaults to NotificationNamespaceChanges,

Jump to

Keyboard shortcuts

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