коммит произвёл
GitHub
родитель
b45ff0be5d
Коммит
717a4d04a9
12
services/cache/lru.go
поставляемый
12
services/cache/lru.go
поставляемый
@@ -70,25 +70,25 @@ func (l *LRU) Purge() error {
|
||||
|
||||
// Set adds the given key and value to the store without an expiry. If the key already exists,
|
||||
// it will overwrite the previous value.
|
||||
func (l *LRU) Set(key string, value interface{}) error {
|
||||
func (l *LRU) Set(key string, value any) error {
|
||||
return l.SetWithExpiry(key, value, 0)
|
||||
}
|
||||
|
||||
// SetWithDefaultExpiry adds the given key and value to the store with the default expiry. If
|
||||
// the key already exists, it will overwrite the previous value
|
||||
func (l *LRU) SetWithDefaultExpiry(key string, value interface{}) error {
|
||||
func (l *LRU) SetWithDefaultExpiry(key string, value any) error {
|
||||
return l.SetWithExpiry(key, value, l.defaultExpiry)
|
||||
}
|
||||
|
||||
// SetWithExpiry adds the given key and value to the cache with the given expiry. If the key
|
||||
// already exists, it will overwrite the previous value
|
||||
func (l *LRU) SetWithExpiry(key string, value interface{}, ttl time.Duration) error {
|
||||
func (l *LRU) SetWithExpiry(key string, value any, ttl time.Duration) error {
|
||||
return l.set(key, value, ttl)
|
||||
}
|
||||
|
||||
// Get the content stored in the cache for the given key, and decode it into the value interface.
|
||||
// return ErrKeyNotFound if the key is missing from the cache
|
||||
func (l *LRU) Get(key string, value interface{}) error {
|
||||
func (l *LRU) Get(key string, value any) error {
|
||||
return l.get(key, value)
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ func (l *LRU) Name() string {
|
||||
return l.name
|
||||
}
|
||||
|
||||
func (l *LRU) set(key string, value interface{}, ttl time.Duration) error {
|
||||
func (l *LRU) set(key string, value any, ttl time.Duration) error {
|
||||
var expires time.Time
|
||||
if ttl > 0 {
|
||||
expires = time.Now().Add(ttl)
|
||||
@@ -184,7 +184,7 @@ func (l *LRU) set(key string, value interface{}, ttl time.Duration) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *LRU) get(key string, value interface{}) error {
|
||||
func (l *LRU) get(key string, value any) error {
|
||||
val, err := l.getItem(key)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Ссылка в новой задаче
Block a user