cache

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package cache provides a lightweight engine for storing key/value pairs.

Index

Constants

View Source
const (
	DirMode   = 0o755              // Directory permissions.
	ExpiredAt = 7 * 24 * time.Hour // The expiry time for storage engine entries.
	SubDir    = "cacheDB"          // The name of the storage engine subdirectory.
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache int // Cache is the type of storage engine.
const (
	Pouet Cache = iota // data cache for the Pouet website, API requests
	Test               // test cache
)

func (Cache) Delete

func (c Cache) Delete(id string) error

Delete deletes a key/value pair from the storage engine.

func (Cache) Path

func (c Cache) Path() (string, error)

Path returns the absolute path to the storage engine directory. If the directory does not exist it will be created.

func (Cache) Read

func (c Cache) Read(id string) (string, error)

Read returns value from the storage engine.

func (Cache) String

func (c Cache) String() string

String returns the name of the cache.

func (Cache) Write

func (c Cache) Write(key, value string, ttl time.Duration) error

Write writes a key/value pair to the storage engine. The key/value pair will be deleted after the ttl time duration has elapsed. If ttl is 0 then the key/value pair will immediately expire.

func (Cache) WriteNoExpire

func (c Cache) WriteNoExpire(key, value string) error

WriteNoExpire writes a key/value pair to the storage engine. The key/value pair will not expire.

Jump to

Keyboard shortcuts

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