Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nowayhecodes/polacache

A deadly simple and thread-safe map cache
https://github.com/nowayhecodes/polacache

cache-storage caching channels concurrent go go-channel golang goroutine thread-safe

Last synced: about 2 months ago
JSON representation

A deadly simple and thread-safe map cache

Awesome Lists containing this project

README

        


iters




Polacache



A deadly simple and thread-safe map cache.




#### What?

Polacache is a deadly simple and thread-safe map cache.
In it's constructor, you set a cleanupInterval, which launchs a goroutine to perform the cleanup loop.

#### Why?

For the fun

#### How?

```go

package main

import (
"time"

pc "github.com/nowayhecodes/polacache"
)

func main() {
cache := pc.New(1 * time.Minute)

exampleItem := pc.Item{
Key: "example",
Value: 42,
}

cache.Set(exampleItem, time.Now().Add(1*time.Hour).Unix())
cache.Get(exampleItem.Key)
cache.Delete(exampleItem.Key)

}

```