diff options
author | 2024-08-14 12:08:24 +0000 | |
---|---|---|
committer | 2024-08-14 12:08:24 +0000 | |
commit | f8d5b9f49c150574442c2d30add41981ac67e97b (patch) | |
tree | e334c632223430673b422a2d8562b494c101d174 /vendor/codeberg.org/gruf/go-structr/cache.go | |
parent | [security] harden account update logic (#3198) (diff) | |
download | gotosocial-f8d5b9f49c150574442c2d30add41981ac67e97b.tar.xz |
update go-structr to v0.8.8 (#3199)
Diffstat (limited to 'vendor/codeberg.org/gruf/go-structr/cache.go')
-rw-r--r-- | vendor/codeberg.org/gruf/go-structr/cache.go | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/vendor/codeberg.org/gruf/go-structr/cache.go b/vendor/codeberg.org/gruf/go-structr/cache.go index c16bf48c8..8fcd4fec4 100644 --- a/vendor/codeberg.org/gruf/go-structr/cache.go +++ b/vendor/codeberg.org/gruf/go-structr/cache.go @@ -20,17 +20,6 @@ func DefaultIgnoreErr(err error) bool { // for initializing a struct cache. type CacheConfig[StructType any] struct { - // Indices defines indices to create - // in the Cache for the receiving - // generic struct type parameter. - Indices []IndexConfig - - // MaxSize defines the maximum number - // of items allowed in the Cache at - // one time, before old items start - // getting evicted. - MaxSize int - // IgnoreErr defines which errors to // ignore (i.e. not cache) returned // from load function callback calls. @@ -48,6 +37,17 @@ type CacheConfig[StructType any] struct { // as the values passed to Put() / Store(), // or by the keys by calls to Invalidate(). Invalidate func(StructType) + + // Indices defines indices to create + // in the Cache for the receiving + // generic struct type parameter. + Indices []IndexConfig + + // MaxSize defines the maximum number + // of items allowed in the Cache at + // one time, before old items start + // getting evicted. + MaxSize int } // Cache provides a structure cache with automated @@ -56,24 +56,24 @@ type CacheConfig[StructType any] struct { // of negative results (errors!) returned by LoadOne(). type Cache[StructType any] struct { - // indices used in storing passed struct - // types by user defined sets of fields. - indices []Index + // hook functions. + ignore func(error) bool + copy func(StructType) StructType + invalid func(StructType) // keeps track of all indexed items, // in order of last recently used (LRU). lru list + // indices used in storing passed struct + // types by user defined sets of fields. + indices []Index + // max cache size, imposes size // limit on the lruList in order // to evict old entries. maxSize int - // hook functions. - ignore func(error) bool - copy func(StructType) StructType - invalid func(StructType) - // protective mutex, guards: // - Cache{}.lruList // - Index{}.data |