nmashchenko / cache

πŸ’Ύ Cache: An in-memory key-value store for Go. Set, retrieve, and delete data seamlessly. Ideal for fast, temporary data storage. πŸš€πŸ”—

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cache Package

The cache package provides a simple in-memory key-value store for Go applications. With it, you can set, get, and delete key-value pairs easily.

Installation

Assuming you have Go installed and set up:

go get -u github.com/exortme1ster/cache

Usage

Initialization

To start, initialize a new cache:

c := cache.New()

Setting a Value

You can store any value associated with a string key and set time after which it will expire:

c.Set("1", 20, time.Second*3)

Getting a Value

Retrieve a value by its key:

value := c.Get("myKey")
if value != nil {
    fmt.Println(value) // Outputs: myValue
}

Deleting a Value

Remove a key and its associated value:

c.Delete("myKey")

Contributing

Feel free to fork the repository and submit pull requests for any improvements or features you think would be useful.

About

πŸ’Ύ Cache: An in-memory key-value store for Go. Set, retrieve, and delete data seamlessly. Ideal for fast, temporary data storage. πŸš€πŸ”—

License:MIT License


Languages

Language:Go 100.0%