dox_cache 3.1.0
dox_cache: ^3.1.0 copied to clipboard
Cache for Dart and the Dox framework. Memory, file and Redis drivers, TTL, locks, tags and remember helpers.
3.1.0 #
- New: the file driver can delete expired and broken files by itself. Set the
prune_everyoption (orFileDriver(pruneEvery: ...)) to runprune()in the background once every that many writes. It is off by default (0). Only one prune runs at a time, and a failed prune is ignored. - Fix:
FileDriver.prune()could delete a new value thatadd,incrementortouchwrote at the same time. Now it takes the same key lock as they do and reads the file again under it. A key that is locked right now is skipped.
3.0.2 #
- Fix:
rememberandrememberForeverthrew on a cache hit whenTwas not a raw JSON type, likeList<String>. Pass the newdecodeoption to turn the cached JSON intoT. Without it,Tmust be a raw JSON type. - Fix:
rememberrunscomputeonce when many calls for the same key run at the same time in one isolate. The others wait for the first. With the newlock: true, callers in other isolates and servers wait too. - Fix:
pullis atomic now. Redis usesGETDEL(needs Redis 6.2 or newer). Drivers get a newpullmethod. - Fix: the file driver keeps each prefix in its own sub folder.
flushdeletes only the files of its own prefix, and keeps temp files of writes that are running. - Change: because of this, files written by older versions are in the base folder and are not found any more. It is a cache, so they are only misses. You can delete the old files in the base folder by hand.
- Fix: a file driver read no longer deletes an expired or broken file. Another isolate may have just written a new value. Use the new
FileDriver.prune()to delete expired and broken files. - Fix: the file driver has locks now (
File.create(exclusive: true)).add,incrementandtouchtake a lock on the key, so they are safe across isolates. - Fix: a Redis prefix with no
:at the end gets one. So the prefixappdoes not match the keys ofapp2. - New:
flexible(key, fresh, stale, compute): stale while revalidate. - New:
touch(key, ttl)sets a new ttl and keeps the value. - New:
getandpulltake a function as the default. It runs only on a miss. - New:
lock.block(timeout, callback)runs the callback while it holds the lock. It throwsLockTimeoutExceptionwhen the time is over.lock.forceRelease()frees a lock of any owner. - New: the Redis option
max_value_bytes. - Faster: tagged
many,putMany,has,pullandrememberread the tag versions once per call. - Faster: the memory driver keeps the expiry as int milliseconds. It does not read the clock for items with no expiry.
hasdoes not decode the value. - Change:
MemoryEntry.expiresAtis anintin milliseconds now.CacheClockhas a newnowMs().
3.0.1 #
- Version bump only, to match the other packages.
3.0.0 #
- The first stable release.
3.0.0-rc.1 #
- Needs
ioredis3.0.1. It fixes a crash on disconnect when the Redis host is a name likelocalhostorredis.
3.0.0-alpha.17 #
- Version bump only, to match the other packages.
3.0.0-alpha.16 #
- Change: uses ioredis
^3.0.0, the first stable ioredis release.
3.0.0-alpha.15 #
- Version bump only, to match the other packages.
3.0.0-alpha.14 #
- Version bump only, to match the other packages.
3.0.0-alpha.13 #
- Version bump only, to match the other packages.
3.0.0-alpha.12 #
- Version bump only, to match the other packages.
3.0.0-alpha.11 #
- Version bump only, to match the other packages.
3.0.0-alpha.10 #
- Version bump only, to match the other packages.
3.0.0-alpha.9 #
- Version bump only, to match the other packages.
3.0.0-alpha.8 #
- Version bump only, to match the other packages.
3.0.0-alpha.7 #
- Perf: the memory driver removes expired items and expired locks in a sweep after many writes. Before, a key that was written once with a ttl and never read again stayed in memory forever.
- Perf: the memory driver with no
max_sizedoes not reorder the map on every hit. The order is only needed for LRU. - Perf: a tagged cache reads all tag versions with one
manycall (oneMGETon Redis).tags(...).flush()raises all tag versions at the same time. Before, each tag was one round trip after the other. - Perf: the Redis driver frees a lock with
EVALSHA. It sends the full script only when Redis does not know it yet. - Perf: the file driver makes the cache folder only when it is missing. Before, it ran
create(recursive: true)on every write. Lock tokens use one sharedRandom.secure().
3.0.0-alpha.6 #
- New
CacheManager.close(). It closes the connections of every store that was built. The Redis driver closes its connection and its pool connections, with no reconnect. Memory, file and null stores do nothing. It is safe to call twice. A store used after it is built again. - New
CacheDriver.close(), for one driver. Custom drivers can override it. The default does nothing.
3.0.0-alpha.5 #
- Version bump only, to match the other packages.
3.0.0-alpha.4 #
- Version bump only, to match the other packages.
3.0.0-alpha.3 #
- New:
getRaw(key)gives the stored value as JSON text, with no decode. Use it to send a cached value as a JSON response. Memory and Redis return the stored text as is. A stored String comes back with its quotes ("bar"). The stored format did not change, so old values still read the same. - Faster
get: a plain store builds the key with no async step.itemKeynow returnsFutureOr<String>. Memorygetcosts about 0.6 µs instead of 0.86 µs. MemorygetRawcosts about 0.3 µs. - New Redis option
pool_size: the most connections one store opens (ioredismaxConnection). Default is 10, the same as before. - Uses
ioredis2.0.0-alpha.2. It sends all commands on one shared connection and writes them together (auto-pipelining). A Redis read costs much less CPU. The cache now uses one connection per store, sopool_sizerarely matters.
3.0.0-alpha.2 #
- Needs Dart 3.13 or newer.
- All dependencies updated to their latest versions.
3.0.0-alpha.1 #
- Uses
ioredis2. Redis error replies throwRedisError. - Redis: no value size limit by default (was 60 KB).
maxValueBytesis still there if you want one. - Redis:
manyuses oneMGET,putManyuses one pipeline,flushusesSCAN+DEL(no Lua). - First release.
CacheManagerwith named stores and custom drivers.- Drivers: memory (with LRU), file, Redis, null.
remember,pull,add,increment,many, tags and atomic locks.