Skip to content

Instantly share code, notes, and snippets.

@jeffotoni
Created March 1, 2025 00:50
Show Gist options
  • Save jeffotoni/60d1679c256f2d9322a4e4ac8c344a80 to your computer and use it in GitHub Desktop.
Save jeffotoni/60d1679c256f2d9322a4e4ac8c344a80 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"time"
"github.com/jeffotoni/gocache"
)
func main() {
cache := gocache.New(5 * time.Minute)
type User struct {
ID int
Name string
}
user := User{ID: 1, Name: "jeffotoni"}
cache.Set("user_1", user, 1*time.Minute)
if val, found := cache.Get("user_1"); found {
fmt.Println("User found in cache:", val)
} else {
fmt.Println("User not found")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment