mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[performance] update go-cache library (#1917)
* update go-cache library Signed-off-by: kim <grufwub@gmail.com> * fix broken test after cache library upgrade Signed-off-by: kim <grufwub@gmail.com> * fix the webfinger test Signed-off-by: kim <grufwub@gmail.com> --------- Signed-off-by: kim <grufwub@gmail.com>
This commit is contained in:
16
vendor/codeberg.org/gruf/go-cache/v3/result/cache.go
generated
vendored
16
vendor/codeberg.org/gruf/go-cache/v3/result/cache.go
generated
vendored
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"reflect"
|
||||
"time"
|
||||
_ "unsafe"
|
||||
|
||||
"codeberg.org/gruf/go-cache/v3/ttl"
|
||||
"codeberg.org/gruf/go-errors/v2"
|
||||
@@ -385,7 +386,7 @@ func (c *Cache[Value]) store(res result[Value]) (evict func()) {
|
||||
|
||||
// Store main entry under primary key, using evict hook if needed
|
||||
c.cache.Cache.SetWithHook(pnext, &ttl.Entry[int64, result[Value]]{
|
||||
Expiry: time.Now().Add(c.cache.TTL),
|
||||
Expiry: c.expiry(),
|
||||
Key: pnext,
|
||||
Value: res,
|
||||
}, func(_ int64, item *ttl.Entry[int64, result[Value]]) {
|
||||
@@ -395,6 +396,19 @@ func (c *Cache[Value]) store(res result[Value]) (evict func()) {
|
||||
return evict
|
||||
}
|
||||
|
||||
//go:linkname runtime_nanotime runtime.nanotime
|
||||
func runtime_nanotime() uint64
|
||||
|
||||
// expiry returns an the next expiry time to use for an entry,
|
||||
// which is equivalent to time.Now().Add(ttl), or zero if disabled.
|
||||
func (c *Cache[Value]) expiry() uint64 {
|
||||
if ttl := c.cache.TTL; ttl > 0 {
|
||||
return runtime_nanotime() +
|
||||
uint64(c.cache.TTL)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type result[Value any] struct {
|
||||
// keys accessible under
|
||||
Keys cacheKeys
|
||||
|
Reference in New Issue
Block a user