Created
March 1, 2025 00:50
-
-
Save jeffotoni/60d1679c256f2d9322a4e4ac8c344a80 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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