(key KeyType, data DataType, duration time.Duration)
| 3 | import "time" |
| 4 | |
| 5 | func (c *Cache[KeyType, DataType]) Set(key KeyType, data DataType, duration time.Duration) { |
| 6 | c.Mutex.Lock() |
| 7 | defer c.Mutex.Unlock() |
| 8 | item := CacheItem[DataType]{ |
| 9 | LifeTime: time.Now().Add(duration).Unix(), |
| 10 | Data: data, |
| 11 | } |
| 12 | c.Items[key] = item |
| 13 | if c.Properties.SetCacheEvent { |
| 14 | c.SetCacheEvent <- key |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | func (c *Cache[KeyType, DataType]) SetWithoutEventTriggering(key KeyType, data DataType, duration time.Duration) { |
| 19 | c.Mutex.Lock() |
no outgoing calls