Skip to content

Instantly share code, notes, and snippets.

View nitishfy's full-sized avatar
🎯
Focusing

Nitish Kumar nitishfy

🎯
Focusing
View GitHub Profile
@nitishfy
nitishfy / main.go
Last active June 7, 2024 11:09
Time To Live (TTL) Cache
package main
import (
"fmt"
"sync"
"time"
)
type Cache[K comparable, V any] struct {
data map[K]item[V]
@alexedwards
alexedwards / cache.go
Last active May 1, 2025 00:58
Generic in-memory cache implementation in Go
package cache
import (
"sync"
"time"
)
// Cache is a basic in-memory key-value cache implementation.
type Cache[K comparable, V any] struct {
items map[K]V // The map storing key-value pairs.