cache

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Add adds a key in the cache with an expiration time
	Add(key string, expiresIn time.Duration) error
	// Remove removes a key from the cache
	Remove(key string)
	// Contains returns true if the key is in the cache and was not expired
	Contains(key string) bool
}

The Cache interface defines the methods that a cache implementation should have

type InMemory

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

InMemory is a simple Cache implementation used for testing and examples

func NewInMemory

func NewInMemory() *InMemory

func (*InMemory) Add

func (i *InMemory) Add(key string, expiresIn time.Duration) error

func (*InMemory) Contains

func (i *InMemory) Contains(key string) bool

func (*InMemory) Remove

func (i *InMemory) Remove(key string)

Jump to

Keyboard shortcuts

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