cache

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package cache provides a set of caching utilities for Go applications.

Index

Constants

View Source
const DefaultDelimiter = ":"

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache[T any] interface {
	Get(ctx context.Context, key string) (T, error)
	GetAndDelete(ctx context.Context, key string) (T, error)
	Exists(ctx context.Context, key string) error
	Set(ctx context.Context, key string, value T, expiration ...time.Duration) error
	Delete(ctx context.Context, key string) error
	Iterator(ctx context.Context, fn func(ctx context.Context, key string, value T) bool) error
	Close(ctx context.Context) error
}

Cache is the interface that wraps the basic Get, Set, and Delete methods.

type NSCache

type NSCache[T any] interface {
	Get(ctx context.Context, ns, key string) (T, error)
	GetAndDelete(ctx context.Context, ns, key string) (T, error)
	Exists(ctx context.Context, ns, key string) error
	Set(ctx context.Context, ns, key string, value T, expiration ...time.Duration) error
	Delete(ctx context.Context, ns, key string) error
	Iterator(ctx context.Context, ns string, fn func(ctx context.Context, key string, value T) bool) error
	Close(ctx context.Context) error
}

NSCache is the interface that wraps the basic Get, Set, and Delete methods.

type ObjectCache

type ObjectCache interface {
	Get(ctx context.Context, key string) (any, error)
	GetAndDelete(ctx context.Context, key string) (any, error)
	Exists(ctx context.Context, key string) error
	Set(ctx context.Context, key string, value any, expiration ...time.Duration) error
	Delete(ctx context.Context, key string) error
	Iterator(ctx context.Context, fn func(ctx context.Context, key string, value any) bool) error
	Close(ctx context.Context) error
}

ObjectCache is the interface that wraps the basic Get, Set, and Delete methods.

type ObjectNSCache

type ObjectNSCache interface {
	Get(ctx context.Context, ns, key string) (any, error)
	GetAndDelete(ctx context.Context, ns, key string) (any, error)
	Exists(ctx context.Context, ns, key string) error
	Set(ctx context.Context, ns, key string, value any, expiration ...time.Duration) error
	Delete(ctx context.Context, ns, key string) error
	Iterator(ctx context.Context, ns string, fn func(ctx context.Context, key string, value any) bool) error
	Close(ctx context.Context) error
}

ObjectNSCache is the interface that wraps the basic Get, Set, and Delete methods.

type Option

type Option func(*Options)

func WithDelimiter

func WithDelimiter(delimiter string) Option

type Options

type Options struct {
	Delimiter string
}

Jump to

Keyboard shortcuts

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