Documentation
¶
Overview ¶
package inmemcache provides a simple in-memory caching mechanism.
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 is a structure that holds a map of cache items. The key is a string.
func (*Cache) Delete ¶
Delete is a method of the Cache structure that deletes an item from the cache, before the item expires. Returns an error if operation fails.
func (*Cache) Get ¶
Get is a method of the Cache structure that retrieves an item from the cache. Returns the item value, time until expiration, and an error, if any.
func (*Cache) Set ¶
Set is a method of the Cache structure that adds an item to the cache. key is a string identifier for the item. value is any type that represents the item itself. ttl is a time.Duration that represents how long the item will live in the cache. tracked is a boolean value; if true, the item's expiry will be tracked, if false, it will not. Returns an error if operation fails.