From e599fa57aa29c932064d6b189c4b37b1b1ff011d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 26 Jun 2026 14:43:54 +0000 Subject: [PATCH] build(deps): bump github.com/jellydator/ttlcache/v3 from 3.4.0 to 3.4.1 Bumps [github.com/jellydator/ttlcache/v3](https://github.com/jellydator/ttlcache) from 3.4.0 to 3.4.1. - [Release notes](https://github.com/jellydator/ttlcache/releases) - [Commits](https://github.com/jellydator/ttlcache/compare/v3.4.0...v3.4.1) --- updated-dependencies: - dependency-name: github.com/jellydator/ttlcache/v3 dependency-version: 3.4.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 +-- .../jellydator/ttlcache/v3/README.md | 12 ++------ .../jellydator/ttlcache/v3/cache.go | 30 +++++++++++++------ vendor/modules.txt | 2 +- 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/go.mod b/go.mod index e11c013a03..4a9237cc86 100644 --- a/go.mod +++ b/go.mod @@ -46,7 +46,7 @@ require ( github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0 github.com/invopop/validation v0.8.0 github.com/jellydator/ttlcache/v2 v2.11.1 - github.com/jellydator/ttlcache/v3 v3.4.0 + github.com/jellydator/ttlcache/v3 v3.4.1 github.com/jinzhu/now v1.1.5 github.com/justinas/alice v1.2.0 github.com/kovidgoyal/imaging v1.8.21 diff --git a/go.sum b/go.sum index 487db1304a..61856f3ca0 100644 --- a/go.sum +++ b/go.sum @@ -682,8 +682,8 @@ github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZ github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc= github.com/jellydator/ttlcache/v2 v2.11.1 h1:AZGME43Eh2Vv3giG6GeqeLeFXxwxn1/qHItqWZl6U64= github.com/jellydator/ttlcache/v2 v2.11.1/go.mod h1:RtE5Snf0/57e+2cLWFYWCCsLas2Hy3c5Z4n14XmSvTI= -github.com/jellydator/ttlcache/v3 v3.4.0 h1:YS4P125qQS0tNhtL6aeYkheEaB/m8HCqdMMP4mnWdTY= -github.com/jellydator/ttlcache/v3 v3.4.0/go.mod h1:Hw9EgjymziQD3yGsQdf1FqFdpp7YjFMd4Srg5EJlgD4= +github.com/jellydator/ttlcache/v3 v3.4.1 h1:bOdXmXiycyK6E6Qjyuj5vl+/vU3SCOoDs8a86NbHjAQ= +github.com/jellydator/ttlcache/v3 v3.4.1/go.mod h1:j7LO12PNghFg5+0v9budMAT4rDK4JY969jb9vOdOBBk= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jhump/protoreflect v1.17.0 h1:qOEr613fac2lOuTgWN4tPAtLL7fUSbuJL5X5XumQh94= github.com/jhump/protoreflect v1.17.0/go.mod h1:h9+vUUL38jiBzck8ck+6G/aeMX8Z4QUY/NiJPwPNi+8= diff --git a/vendor/github.com/jellydator/ttlcache/v3/README.md b/vendor/github.com/jellydator/ttlcache/v3/README.md index d941495fa2..b010bbcd2d 100644 --- a/vendor/github.com/jellydator/ttlcache/v3/README.md +++ b/vendor/github.com/jellydator/ttlcache/v3/README.md @@ -20,10 +20,6 @@ go get github.com/jellydator/ttlcache/v3 ``` -## Status -The `ttlcache` package is stable and used by [Jellydator](https://jellydator.com/), -as well as thousands of other projects and organizations in production. - ## Usage The main type of `ttlcache` is `Cache`. It represents a single in-memory data store. @@ -162,7 +158,7 @@ func main() { ttlcache.WithMaxCost[string, string](5120, func(item ttlcache.CostItem[string, string]) uint64 { // Note: The below line doesn't include memory used by internal // structures or string metadata for the key and the value. - return len(item.Key) + len(item.Value) + return uint64(len(item.Key) + len(item.Value)) }), ) @@ -170,11 +166,7 @@ func main() { } ``` -## Examples & Tutorials +## Examples See the [example](https://github.com/jellydator/ttlcache/tree/v3/examples) directory for applications demonstrating how to use `ttlcache`. - -If you want to learn and follow along as these example applications are -built, check out the tutorials below: -- [Speeding Up HTTP Endpoints with Response Caching in Go](https://jellydator.com/blog/speeding-up-http-endpoints-with-response-caching-in-go/) diff --git a/vendor/github.com/jellydator/ttlcache/v3/cache.go b/vendor/github.com/jellydator/ttlcache/v3/cache.go index 1cfcaf9141..d860225765 100644 --- a/vendor/github.com/jellydator/ttlcache/v3/cache.go +++ b/vendor/github.com/jellydator/ttlcache/v3/cache.go @@ -88,14 +88,11 @@ func New[K comparable, V any](opts ...Option[K, V]) *Cache[K, V] { // updateExpirations updates the expiration queue and notifies // the cache auto cleaner if needed. +// 'oldExpiresAt' should reflect the front of the expiration queue +// before any item mutations. // Not safe for concurrent use by multiple goroutines without additional // locking. -func (c *Cache[K, V]) updateExpirations(fresh bool, elem *list.Element) { - var oldExpiresAt time.Time - - if !c.items.expQueue.isEmpty() { - oldExpiresAt = c.items.expQueue[0].Value.(*Item[K, V]).expiresAt - } +func (c *Cache[K, V]) updateExpirations(fresh bool, elem *list.Element, oldExpiresAt time.Time) { if fresh { c.items.expQueue.push(elem) @@ -151,9 +148,14 @@ func (c *Cache[K, V]) set(key K, value V, ttl time.Duration) *Item[K, V] { item := elem.Value.(*Item[K, V]) oldItemCost := item.cost + var oldExpiresAt time.Time + if !c.items.expQueue.isEmpty() { + oldExpiresAt = c.items.expQueue[0].Value.(*Item[K, V]).expiresAt + } + item.update(value, ttl) - c.updateExpirations(false, elem) + c.updateExpirations(false, elem, oldExpiresAt) if c.options.maxCost != 0 { c.cost = c.cost - oldItemCost + item.cost @@ -185,11 +187,16 @@ func (c *Cache[K, V]) set(key K, value V, ttl time.Duration) *Item[K, V] { ttl = c.options.ttl } + var oldExpiresAt time.Time + if !c.items.expQueue.isEmpty() { + oldExpiresAt = c.items.expQueue[0].Value.(*Item[K, V]).expiresAt + } + // create a new item item := NewItemWithOpts(key, value, ttl, c.options.itemOpts...) elem = c.items.lru.PushFront(item) c.items.values[key] = elem - c.updateExpirations(true, elem) + c.updateExpirations(true, elem, oldExpiresAt) if c.options.maxCost != 0 { c.cost += item.cost @@ -231,8 +238,13 @@ func (c *Cache[K, V]) get(key K, touch bool, includeExpired bool) *list.Element c.items.lru.MoveToFront(elem) if touch && item.ttl > 0 { + var oldExpiresAt time.Time + if !c.items.expQueue.isEmpty() { + oldExpiresAt = c.items.expQueue[0].Value.(*Item[K, V]).expiresAt + } + item.touch() - c.updateExpirations(false, elem) + c.updateExpirations(false, elem, oldExpiresAt) } return elem diff --git a/vendor/modules.txt b/vendor/modules.txt index 51378bd8ed..8f7fb6bde2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -827,7 +827,7 @@ github.com/jbenet/go-context/io # github.com/jellydator/ttlcache/v2 v2.11.1 ## explicit; go 1.15 github.com/jellydator/ttlcache/v2 -# github.com/jellydator/ttlcache/v3 v3.4.0 +# github.com/jellydator/ttlcache/v3 v3.4.1 ## explicit; go 1.23.0 github.com/jellydator/ttlcache/v3 # github.com/jinzhu/now v1.1.5