cash - is a simple and fast library written in go and is used to hash any data.
Download: go get -u github.com/avalonprod/in-memory-cash
.
Set
cash.Set(key, data)
- indicator under which the value data will be written
Get
result, found := cash.Get(key)
- key identifier by which to get the value
- as a result, the result is returned if nothing is found, zero is returned
- в found returns true if the element is found and false if no such element exists
Delete
err := cash.Delete(key)
- key id at address need to delete value
- returns an error if the element is not found
package main
import "log"
import (
cash: "github.com/avalonprod/in-memory-cash"
"log"
"fmt"
)
func main() {
cash.Set("user", "John")
value, found := cash.Get("user")
if !found {
fmt.Print("Element is not found.")
}
err := cash.Delete("user")
if err != nil {
log.Fatal("Error element is not found")
}
}