Skip to content
This repository has been archived by the owner on Nov 6, 2024. It is now read-only.

united-manufacturing-hub/expiremap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ExpireMap

This go package provides a map with expiring key-value pairs.

Installation

go get github.com/united-manufacturing-hub/expiremap

Usage

package main

import (
	"fmt"
	"github.com/united-manufacturing-hub/expiremap/pkg/expiremap"
	"time"
)

func main() {
	var exMap = expiremap.New[string, string]()
	exMap.Set("key", "value") // 10 seconds
	val, ok := exMap.Load("key")                   // "value"
	fmt.Println(val)
	fmt.Println(ok)
	time.Sleep(11 * time.Second)
	val, ok = exMap.Load("key") // nil
	fmt.Println(val)
	fmt.Println(ok)
}