cache

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package cache implements a simple in-memory cache.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

An in-memory cache.

func New

func New() *Cache

New creates a new cache and returns it.

func (*Cache) Clear

func (c *Cache) Clear()

Clear removes all cache keys.

func (*Cache) Delete

func (c *Cache) Delete(key any)

Delete deletes an item from the cache

func (*Cache) Exists

func (c *Cache) Exists(key any) bool

Exists reports wether a key exists

func (*Cache) Get

func (c *Cache) Get(key any) (any, bool)

Get returns an item if it exits

func (*Cache) Reorganize

func (c *Cache) Reorganize()

Reorganize removes all expired keys

func (*Cache) Set

func (c *Cache) Set(key any, value any, timeout time.Duration)

Set stores an item in the cache.

If an item with the same key already exists it will be overwritten. An item with timeout = 0 never expires

Jump to

Keyboard shortcuts

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