cache

package
v1.0.0-rc1.0...-e18caea Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// For use with functions that take an expiration time.
	NoExpiration time.Duration = -1
	// For use with functions that take an expiration time. Equivalent to
	// passing in the same expiration duration as was given to New() or
	// NewFrom() when the cache was created (e.g. 5 minutes.)
	DefaultExpiration time.Duration = 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache is a abstraction over go-cache.

func NewCache

func NewCache(ttl time.Duration, cleanupInterval time.Duration) *Cache

NewCache creates a go-cache with expiration(ttl) time and cleanupInterval.

func (*Cache) Get

func (c *Cache) Get(request string) (interface{}, bool)

Get the value associated with request from the cache

func (*Cache) Set

func (c *Cache) Set(request string, response interface{})

Set the value of the key "request" to "rersponse" with default expiration time.

Jump to

Keyboard shortcuts

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