lee

package module
v0.0.0-...-a9d9bd3 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package lee provides a simple time-based eviction 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
}

Cache manages a set of cached entries. It is safe for concurrent use.

func New

func New() Cache

New creates and returns a new Cache.

func (*Cache) Get

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

Get retrieves a value from the cache. It returns the value associated with the key and a boolean indicating whether the key was found. The method first checks if the entry is still valid based on the ttl. If it is not, it removes the entry from the cache.

func (*Cache) Put

func (c *Cache) Put(key string, value any, ttl int)

Put adds or updates an entry in the cache with the specified ttl (in seconds). It locks the cache, updates the entry, and unlocks the cache.

Jump to

Keyboard shortcuts

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