cache

package
v0.14.4 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package cache implements generic cache used throughout this application. By default it persists values to disk cache (using BadgerDB). Mainly the cache is used for STS Temporary Session Credentials and Yubikey OATH Application Password caching.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Key added in v0.11.0

func Key(prefix string, checksum string) string

Types

type Cache added in v0.11.0

type Cache struct {
	// contains filtered or unexported fields
}

Cache struct is used to define all the high-level repository methods, that internally call the low-level (disk cache) repository (which has the same interface to interact with BadgerDB).

func (*Cache) Close added in v0.12.10

func (c *Cache) Close() error

Close the cache connection.

func (*Cache) Delete added in v0.12.10

func (c *Cache) Delete(key string) error

Delete a value from cache.

func (*Cache) DeleteAll added in v0.12.10

func (c *Cache) DeleteAll() error

DeleteAll clears the whole cache.

func (*Cache) DeleteByPrefix added in v0.12.10

func (c *Cache) DeleteByPrefix(keyPrefix string) error

DeleteByPrefix clears all values with key prefix from cache.

func (*Cache) Read added in v0.12.10

func (c *Cache) Read(key string) ([]byte, error)

Read a value from cache.

func (*Cache) Write added in v0.12.10

func (c *Cache) Write(key string, data []byte, ttl time.Duration) error

Write a value to cache.

type Repository added in v0.12.10

type Repository interface {
	Write(key string, value []byte, ttl time.Duration) error
	Read(key string) ([]byte, error)
	Delete(key string) error
	DeleteByPrefix(keyPrefix string) error
	DeleteAll() error
	Close() error
}

Repository interface defines the methods that any cache implementation must implement.

func New

func New(cachePath string) Repository

Initializes a new (disk-based) cache.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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