Modernize run

This commit is contained in:
2025-06-20 08:02:26 +01:00
parent c400251625
commit c233aa92ef
26 changed files with 348 additions and 410 deletions
+3 -3
View File
@@ -9,7 +9,7 @@ import (
// CacheItem represents an item stored in the cache with its associated metadata.
type CacheItem struct {
// Value is the cached data of any type.
Value interface{}
Value any
// ExpiresAt is the timestamp when this item should be considered expired.
ExpiresAt time.Time
@@ -68,7 +68,7 @@ func NewCache() *Cache {
// If the key does not exist and the cache is full, the least recently used item is evicted
// before adding the new item.
// The expiration duration is relative to the time Set is called.
func (c *Cache) Set(key string, value interface{}, expiration time.Duration) {
func (c *Cache) Set(key string, value any, expiration time.Duration) {
c.mutex.Lock()
defer c.mutex.Unlock()
@@ -106,7 +106,7 @@ func (c *Cache) Set(key string, value interface{}, expiration time.Duration) {
// Accessing an item moves it to the most recently used position in the LRU list.
// If the item does not exist or has expired, nil and false are returned, and the
// expired item is removed from the cache.
func (c *Cache) Get(key string) (interface{}, bool) {
func (c *Cache) Get(key string) (any, bool) {
c.mutex.Lock()
defer c.mutex.Unlock()