cache

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(item Entry) ([]byte, error)

Encode serializes a cache Entry (map[string]interface{}) into JSON bytes for storage. This function converts cache entries into a portable format that can be stored in various cache backends (Redis, Badger, etc.) and survives application restarts. Returns the JSON-encoded byte slice or an error if marshaling fails.

func UsesBadger

func UsesBadger() bool

Checks if any framework service is configured to use Badger. Returns true if the CACHE environment variable

func UsesRedis

func UsesRedis() bool

Checks if any framework service is configured to use Redis. Returns true if any of the CACHE, SESSION_TYPE, or QUEUE_TYPE environment variable

Types

type Cache

type Cache interface {
	Has(string) (bool, error)
	Get(string) (interface{}, error)
	Set(string, interface{}, ...int) error
	Forget(string) error
	EmptyByMatch(string) error
	Empty() error
}

type Entry

type Entry map[string]interface{}

func Decode

func Decode(data []byte) (Entry, error)

Decode deserializes JSON bytes back into a cache Entry for use by the application. This function reconstructs cache entries from their stored JSON representation, allowing cached data to be retrieved and used regardless of the underlying storage backend. Returns the decoded Entry or an error if the data is not valid JSON or cannot be unmarshaled.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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