cache

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package cache implements cache storage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MetaTTL         time.Duration `default:"240h" description:"Metadata TTL"     long:"meta_ttl"`
	DataTTL         time.Duration `default:"24h"  description:"Data TTL"         long:"data_ttl"`
	CleanupInterval time.Duration `default:"10m"  description:"Cleanup interval" long:"cleanup"`
}

Config holds Storage Config.

type Storage

type Storage struct {
	Meta    *zcache.Cache[string, *gen.ItemMeta]
	Data    *zcache.Cache[string, string]
	DataTTL time.Duration
}

Storage implements data storage.

func New

func New(cfg Config) Storage

New returns new Storage object.

func (Storage) GetData

func (store Storage) GetData(id string) (*gen.ItemData, error)

GetData returns item data (secret).

func (Storage) GetMeta

func (store Storage) GetMeta(id string) (*gen.ItemMeta, error)

GetMeta returns item metadata.

func (Storage) Items

func (store Storage) Items(owner string) (*gen.ItemList, error)

Items returns items, created by current user.

func (Storage) SetItem added in v1.0.3

func (store Storage) SetItem(owner string, req *gen.NewItemRequest) (*ulid.ULID, error)

SetItem prepares and saves item metadata and secret.

func (Storage) Stats

func (store Storage) Stats(owner string) (*gen.StatsResponse, error)

Stats returns global and user's item counters.

Jump to

Keyboard shortcuts

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