cachego

package module
v0.0.8 Latest Latest
Warning

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

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

README

cachego

GitHub tag (with filter) Go Reference Maintainability

Multi-provider Caching library I've come up with in order unify my apps.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheInterface

type CacheInterface interface {
	Init() error
	Get(cacheKey string) ([]byte, bool, error)
	GetConfig() config.CacheGoConfig
	Set(cacheKey string, item []byte) error
	GetItemTTL(cacheKey string) (time.Duration, bool, error)
	ExtendTTL(cacheKey string, item []byte) error
}

The above code defines a CacheInterface type in Go that represents a cache with methods for initialization, getting and setting items, and managing item time-to-live (TTL). @property {error} Init - The Init method is used to initialize the cache. It can be used to set up any necessary data structures or connections required for caching. @property Get - The Get method retrieves an item from the cache based on the provided cache key. It returns the item, a boolean indicating whether the item was found in the cache, and an error if any occurred. @property {error} Set - The Set method is used to store an item in the cache. It takes a cacheKey string as the identifier for the item and the item itself as the value to be stored in the cache. @property GetItemTTL - GetItemTTL is a method that retrieves the time-to-live (TTL) value for a specific item in the cache. The TTL represents the amount of time that the item will remain in the cache before it expires and is automatically removed. The method returns the TTL value as a time.Duration, @property {error} ExtendTTL - ExtendTTL is a method that extends the time to live (TTL) of a cached item. It takes a cacheKey string and an item interface as parameters. The cacheKey is used to identify the cached item, and the item is the updated value that will be stored in the cache.

var CacheInstance CacheInterface

The line `var CacheInstance CacheInterface` is declaring a variable named `CacheInstance` of type `CacheInterface`. This variable will be used to store an instance of a cache that implements the `CacheInterface` interface.

func CacheInit

func CacheInit(ctx context.Context, cacheConfig config.CacheGoConfig) (CacheInterface, error)

The function `CacheInit` initializes and returns a cache instance based on the provided configuration.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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