Implements an in-memory cache key:value (similar to C# MemoryCache)
1.Install
go get github.com/jiansoft/carrot
2.Use examples
import (
"time"
"github.com/jiansoft/carrot"
)
func main() {
//Keep an item in memory
carrot.Default.Delay("qq", "Qoo", time.Second)
//Read returns the value if the key exists in the cache and it's not expired.
val, ok := carrot.Default.Read("qq")
//Have eturns true if the memory has the item and it's not expired.
yes := carrot.Default.Have("qq")
//Removes an item from the memory
carrot.Default.Forget("qq")
Copyright (c) 2023
Released under the MIT license: