Skip to content

avalonprod/in-memory-cash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Fast and simple library written in go for cashing.


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.

Methods

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

Example

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")
	}
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages