Releases: jellydator/ttlcache
Version 2.1.0
2.1.0 (October 2020)
API changes
SetCacheSizeLimit(limit int)
a call was contributed to set a cache limit. #35
Version 2
2.0.0 (July 2020)
Fixes #29, #30, #31
Behavioural changes
Remove(key)
now also calls the expiration callback when it's setCount()
returns zero when the cache is closed
API changes
SetLoaderFunction
allows you to provide a function to retrieve data on missing cache keys.- Operations that affect item behaviour such as
Close
,Set
,SetWithTTL
,Get
,Remove
,Purge
now return an error with standard errorsErrClosed
anErrNotFound
instead of a bool or nothing SkipTTLExtensionOnHit
replacesSkipTtlExtensionOnHit
to satisfy golint- The callback types are now exported
Remove vendoring, and change Close behaviour
This release has two points:
- Remove vendoring and continue with modules only. I consider this not breaking as this is a possibility since Go 1.11 and is not an issue on the current Go 1.13 and 1.14 build.
- Fixed issue #28: call
expirationCallback
automatically oncache.Close()
Note that while all expirationCallback
routines are called for all items in the cache on cache.Close()
there is no synchronized wait. This is the current behavior for expiration at runtime. It's up to the cache creator to decide whether to built in synchronization for a full clean shutdown. See TestCache_ExpirationOnClose(t *testing.T) for a sample with synchronization.
Add a Close method to clean up resources
In issue #23 it became clear that people want to create and drop caches on the fly. There was a goroutine leak in that case.
- The goroutine leak is fixed, after calling
Close
, an empty cache remains. - Tests are now done with uber goroutine leak detector.
- Test logging has been cleaned.
- 100% coverage, not by synthetic testing but by building up the test suite with seen issues over time.
Same release as 1.5.0 but proper go module tag.
See 1.5.0 tag for notes.
Fix crash, fix timer allocation
Depending on your usage, the issues fixed may improve stability of your programs:
#20 : A crash was observed by me in a configuration that was not in the test suite. This subsequently triggered some rework on the locking.
Fix data race, fix memory usage
Depending on your usage, the issues fixed may improve stability of your programs:
#17 : Fixes a data race on read and introduces RWLock which is better for performance on heavy workloads.
#18 : Addresses excessive memory usage if you have a long running timer as global TTL. if pprof shows most of your memory in use coming from ttlcache then you must upgrade:
[...]
----------------------------------------------------------+-------------
flat flat% sum% cum cum% calls calls% + context
----------------------------------------------------------+-------------
1034.31MB 100% | github.com/ReneKroon/ttlcache.(*Cache).startExpirationProcessing
983.58MB 82.74% 82.74% 1034.31MB 87.00% | time.NewTimer
50.73MB 4.90% | time.startTimer
----------------------------------------------------------+-------------
Bug Fix
Add setting to skip automatic TTL extension
This fixes issue #12 and updates the Travis CI to current go versions.
SkipTtlExtensionOnHit allows the user to change the cache behaviour. When this flag is set to true it will
no longer extend TTL of items when they are retrieved using Get, or when their expiration condition is evaluated using SetCheckExpirationCallback.
Fix bug when using SetCheckExpirationCallback
This fixes issue #14, which can occur when using SetCheckExpirationCallback and it returns false on the last element in the list.