Skip to content

nowayhecodes/polacache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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?

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)

}