cacheDB

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Initialize

func Initialize()

Initialize initializes the cache database connection.

No parameters. No return values.

Types

type Cache

type Cache[T any] struct {
	// contains filtered or unexported fields
}

Cache struct

func NewCache

func NewCache[T any](name string, ttl time.Duration) *Cache[T]

NewCache creates a new pointer to Cache struct.

Parameters: - name: a string representing the name of the cache. - ttl: a time.Duration representing the time to live for the cache items. Returns a pointer to Cache[T].

func (*Cache[T]) Del

func (c *Cache[T]) Del(ctx context.Context) error

Del delete data in cachedDB.

ctx: The context for the cache operation. Returns an error.

func (*Cache[T]) Many

func (c *Cache[T]) Many(ctx context.Context) ([]T, error)

Many retrieves multiple items of type T from the cache.

ctx: The context for the cache operation. Returns a slice of retrieved items of type T and an error.

func (*Cache[T]) One

func (c *Cache[T]) One(ctx context.Context) (*T, error)

One retrieves a single item of type T from the cache.

ctx: The context for the cache operation. Returns a pointer to the retrieved item of type T and an error.

func (*Cache[T]) Set

func (c *Cache[T]) Set(ctx context.Context, data any) error

Set save data in cacheDB.

ctx: The context for the cache operation. data: The data to be saved in the cache. Returns an error.

Jump to

Keyboard shortcuts

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