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" | |
| "sync" | |
| "time" | |
| ) | |
| type Cache[K comparable, V any] struct { | |
| data map[K]item[V] |
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 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. |