Debian Codegraph @

CHANGES.rst

raw
1 Changelog
2 =========
3
4 Version 2.5.1
5 -------------
6
7 Released 2026-09-04
8
9 - ``@cached`` no longer treats view arguments named ``path`` or ``query_args``
10 as the explicit ``make_cache_key()`` arguments of the same name. :issue:`679`
11
12
13 Version 2.5.0
14 -------------
15
16 Released 2026-08-24
17
18 - Specifying timeouts now also works with ``datetime.timedelta``. :issue:`266`
19 - Add config option ``CACHE_SERIALIZER`` to set the cachelib serializer the backend uses.
20 :issue:`209`
21 - cachelib backends can now be configured directly via ``CACHE_TYPE="cachelib.ValkeyCache``.
22 :pr:`668`
23 - ``@cached`` and ``@memoize`` now go through the public ``Cache`` proxy methods
24 (``get``, ``set``, ``has``, ``delete``, ``delete_many``, ``get_many`` and
25 ``set_many``) instead of calling the backend directly. :issue:`417`
26 - Document that ``CACHE_REDIS_HOST`` accepts an already created ``redis.Redis``
27 client instead of a host name, which allows sharing a connection pool with
28 other extensions and the application. :issue:`629`
29 - Send Signals for cache hits and misses. :pr:`#237` and :pr:`667`
30 - Include ``key_prefix`` when building ``@cached(query_string=True)`` cache
31 keys. :issue:`302`
32 - Add ``Cache.delete_cached()`` and extend ``make_cache_key()`` with ``path`` and ``query_args``
33 arguments to make deleting views decorated with ``cached(query_string=True)`` possible.
34 :issue:`243`
35 - Use ``hashlib.sha256`` instead of ``hashlib.md5`` for hashing the cache keys.
36 This changes the generated keys, so entries cached by an earlier version become
37 obsolete. If you wish to still use hashlib.md5 set the config
38 ``CACHE_HASH_METHOD = hashlib.md5``. :pr:`563`
39 - Add ``CACHE_HASH_METHOD`` to set the hash method used for the cache keys of
40 ``@cached`` and ``@memoize``.
41 - Drop support for Python 3.10 and require cachelib 0.17.0+
42 - ``CACHE_IGNORE_ERRORS`` is now used by every backend instead of only
43 ``SimpleCache`` and ``FileSystemCache``.
44 - The ``delete_many`` method is now used from cachelib. A key
45 that does not exist counts as deleted, and with ``CACHE_IGNORE_ERRORS`` set to
46 ``False`` a ``RuntimeError`` is raised if the key could not be deleted.
47 - Clarify docs about decorator order regarding ``@staticmethod`` and ``@classmethod``
48 when memoizing. :issue:`440`
49 - Remove the deprecated lowercase ``CACHE_TYPE`` names (``null``, ``simple``,
50 ``filesystem``, ``redis``, ``redissentinel``, ``rediscluster``, ``uwsgi``,
51 ``memcached``, ``gaememcached``, ``saslmemcached`` and
52 ``spreadsaslmemcached``)
53 - Call ``@memoize`` ``forced_update`` callbacks once per decorated function
54 call instead of once while making the key and again before cache lookup.
55 :issue:`387`
56 - Add an ``is_stale`` option to ``@cached`` and ``@memoize``. It is called on a
57 cache hit with the cached value. Unlike ``forced_update`` it uses the value itself
58 to check whether the cache is stale. Can be used in combination with ``forced_update``
59 :issue:`392`
60 - ``@cached`` now caches an ``HTTPException`` raised by the view (i.e. through ``abort()``).
61 This exception will now be re-raises on a cache hit. Use ``response_filter``,
62 to keep the exception out of the cache. :issue:`444`
63 - Fix a ``@memoize`` cache-key collision when a parameter has a falsy
64 default (e.g. ``0``, ``""``, ``False``): calling with the default was
65 keyed the same as passing ``None``, returning the wrong cached result.
66 :pr:`656`
67 - ``@cached`` and ``@memoize`` now preserve the wrapped function's
68 signature and expose ``uncached``, ``cache_timeout``, ``make_cache_key``
69 ``delete_memoized`` to type checkers.
70 - Fix ``@cached(response_hit_indication=True)`` appending a new
71 ``after_request`` function to the app on every request.
72 - Fix a view returning an iterator of strings, for example when using
73 ``flask.stream_template`` it previously returned a list of JSON strings instead
74 of the rendered template. :issue:`511`
75 - Fix ``__caching_id__`` never being usable. ``@memoize`` silently ignored that
76 and ran the function uncached.
77 - Add ``CACHE_FILE_HASH_METHOD`` config option to ``FileSystemCache`` to allow
78 using a different hash function for cache keys. :pr:`660`
79 - Add ``pool_size`` and ``pool_blocking`` to make ``MemcachedCache`` backends
80 thread-safe. :pr:`663`
81 - Modify ``SimpleCache`` docs as it's now thread-safe using an ``RLock`` for all
82 operations. :pr:`663`
83 - ``delete_memoized`` now takes the instance from a bound method, so
84 ``cache.delete_memoized(obj.method, 1)`` deletes the cache for
85 ``obj.method(1)`` instead of silently deleting nothing.
86 The current behaviour by passing the instance keeps working as well.
87 :issue:`554`
88 - The ``{% cache %}`` Jinja tag no longer propagates backend errors. If the
89 cache is unavailable, the block is rendered normally instead of raising,
90 matching the existing behavior of ``@memoize``. :issue:`564` :pr:`565`
91 - Fix ``@memoize`` invalidating a function's entire cache by not updating the
92 memoize version key's timeout. It is now refreshed each time an entry is written,
93 with that entry's own timeout. :issue:`531`
94
95
96 Version 2.4.1
97 -------------
98
99 Released 2026-07-08
100
101 - Use ``pallets_sphinx_themes`` for the documentation.
102 - Type ``CachedResponse.__init__`` so it doesn't trigger mypy ``[no-untyped-call]``
103 in strict downstream codebases. :issue:`628`
104 - Docs: clarify that ``@memoize`` uses ``repr(obj)``
105 (or ``__caching_id__``) for the ``self``/``cls`` identity, not Python's
106 :func:`id`. :issue:`555`
107 - Fix test failure with pytest 9.1. :issue:`651`
108
109
110 Version 2.4.0
111 -------------
112
113 Released 2026-04-17
114
115 - Modernize project setup
116 - Update ``intersphinx_mapping`` for Sphinx 8 compatibility. :pr:`599`, :issue:`598`
117 - Pass CACHE_OPTIONS as kwargs to redis_from_url. :pr:`591`
118 - Pass sentinel_kwargs to redis client via CACHE_OPTIONS :pr:`626`
119 - Fix ``response_hit_indication`` return True always. :pr:`579`, :pr:`596`, :issue:`595`, :issue:`570`
120 - Use ``FORWARDREF`` annotation format when introspecting decorated
121 functions so that ``@memoize`` / ``@cached`` work with
122 ``TYPE_CHECKING``-only annotations on Python 3.14. :issue:`636`
123
124
125 Version 2.3.1
126 -------------
127
128 Released 2025-02-22
129
130 - Relax cachelib version to allow latest releases
131
132
133 Version 2.3.0
134 -------------
135
136 Released 2024-05-04
137
138 - Added ``response_hit_indication`` flag to ``Cache.cached`` decorator for appending 'hit_cache' headers to responses, indicating cache hits.
139
140
141 Version 2.2.0
142 -------------
143
144 - Drop python 3.7 support
145 - python 3.11 officially supported
146 - Fix issue causing `args_to_ignore` to not work with `flask_caching.Cache.memoize` decorator when keyword arguments were used in the decorated function call
147
148
149 Version 2.1.0
150 -------------
151
152 Released 2024-10-08
153
154 - fix type signature in ``flask_caching.utils.make_template_fragment_key``. :pr:`430`
155 - Added docs and example for make_cache_key
156 - support Flask 3
157
158
159
160 Version 2.0.2
161 -------------
162
163 Released 2023-01-12
164
165 - fix issue with boto3 dependencie due to latest cachelib released
166 - migrate ``flask_caching.backends.RedisCluster`` dependency from redis-py-cluster to redis-py
167 - bug fix: make the ``make_cache_key`` attributed of decorated view functions writeable. :pr:`431`, :issue:`97`
168
169
170
171 Version 2.0.1
172 -------------
173
174 Released 2022-07-30
175
176 - Relax dependency pin to allow Flask 2.x.x
177
178
179 Version 2.0.0
180 -------------
181
182 Released 2022-06-26
183
184 - fix bug where ``flask_caching.backends.RedisSentinelCache.get_many`` would query wrong host&port combination. :pr:`372`
185 - Remove ``flask_caching.backends.FileSystemCache`` method overrides. It now shares 100% of ``cachelib.FileSystemCache`` API and is fully compatible. Functionality relient on implementation details of said overrides from older releases might not work anymore. :pr:`369`
186 - Add proxy to underlaying ``has`` method of cache clients. :pr:`356`
187 - ``flask_caching.backends.FileSystemCache`` now stores timestamps in a universal (non-frammed) way following the lastest version of ``cachelib.FileSystemCache``. The change also reduces overhead from 17 bytes (via previous method using pickle) to 4 bytes (using python's ``struct``). This, however, will break compatibily since older timestamps are serialized with a different strategy.
188
189
190 Version 1.11.1
191 --------------
192
193 Released 2022-05-27
194
195 - Add cachelib to setup.py: :pr:`354`
196
197
198 Version 1.11.0
199 --------------
200
201 Released 2022-05-27
202
203 - Add suport for cached/memoized generators. :pr:`286`
204 - Add support for Flask 2.0 async. :pr:`282`
205 - Cachelib is now used as backend. :pr:`308`
206 - Drop support for python 3.6. :pr:`332`
207 - Add support for dynamic cache timeouts `#296`
208 - Fix bug in ``CACHE_OPTIONS`` reading for redis in ``RedisSentinelCache``. :pr:`343`
209
210
211 Version 1.10.1
212 --------------
213
214 Released 2021-03-17
215
216 - A ``GoogleCloudStorageCache`` backend has been added to the user contributed
217 caching backends. :pr:`214`
218 - Fix a regression introduced in the last release which broke all applications
219 subclassing the ``Cache`` class.
220 - Add test_generic_get_bytes test case.
221 :pr:`236`
222 - Various improvements and fixes.
223
224
225 Version 1.10.0
226 --------------
227
228 Released 2021-03-04
229
230 - **Important**: The way caching backends are loaded have been refactored.
231 Instead of passing the name of the initialization function one can now use
232 the full path to the caching backend class.
233 For example:
234 ``CACHE_TYPE="flask_caching.backends.SimpleCache"``.
235 In the next major release (2.0), this will be the only supported way.
236 - UWSGICache is not officially supported anymore and moved to the user
237 contributed backends.
238 - Switch from Travis-CI to GitHub Actions
239 - Fix add() in RedisCache without a timeout.
240 :pr:`218`
241 - Fix error in how the FileSystemCache counts the number of files.
242 :pr:`210`
243 - Type Annotations have been added.
244 :pr:`198`
245 - Add some basic logging to SimpleCache and FileSystemCache for better
246 observability.
247 :pr:`203`
248 - Add option in memoize to ignore args
249 :pr:`201`
250 - Stop marking wheels as Python 2 compatible.
251 :pr:`196`
252 - Fix ``default_timeout`` not being properly passed to its super constructor.
253 :pr:`187`
254 - Fix ``kwargs`` not being passed on in function ``_memoize_make_cache_key``.
255 :pr:`184`
256 - Add a Redis Cluster Mode caching backend.
257 :pr:`173`
258 - Do not let PIP install this package on unsupported Python Versions.
259 :pr:`179`
260 - Fix uWSGI initialization by checking if uWSGI has the 'cache2' option
261 enabled. :pr:`176`
262 - Documentation updates and fixes.
263
264
265 Version 1.9.0
266 -------------
267
268 Released 2020-06-02
269
270 - Add an option to include the functions source code when generating the cache
271 key. :pr:`156`
272 - Add an feature that allows one to completely control the way how cache keys
273 are generated. For example, one can now implement a function that generates a
274 cache key the based on POST requests.
275 :pr:`159`
276 - Fix the cache backend naming collisions by renaming them from ``simple`` to
277 ``simplecache``, ``null`` to ``nullcache`` and ``filesystem`` to
278 ``filesystemcache``.
279 - Explicitly pass the ``default_timeout`` to ``RedisCache`` from
280 ``RedisSentinelCache``.
281 - Use ``os.replace`` instead of werkzeug's ``rename`` due to Windows raising an
282 ``OSError`` if the dst file already exist.
283 - Documentation updates and fixes.
284
285
286 Version 1.8.0
287 -------------
288
289 Released 2019-11-24
290
291 - **BREAKING:** Removed support for Python 2. Python 3.5 and upwards are
292 supported as of now.
293 - Add option to specify if ``None`` is a cached value or not. See
294 :pr:`140` and
295 `#141`
296 - Allow to use ``__caching_id__`` rather than ``__repr__`` as an object
297 caching key.
298 :pr:`123`
299 - The RedisCache backend now support generating the key_prefix via a callable.
300 :pr:`109`
301 - Emit a warning if the ``CACHE_TYPE`` is set to ``filesystem`` but no
302 ``CACHE_DIR`` is set.
303 - Fixes Google App Engine Memcache backend.
304 See issue `#120` for
305 more details.
306 - Various documentation updates and fixes.
307
308
309 Version 1.7.2
310 -------------
311
312 Released 2019-05-28
313
314 **This is the last version supporting Python 2!**
315
316 - Do not run a cached/memoized function if the cached return value is None.
317 :pr:`108`
318
319
320 Version 1.7.1
321 -------------
322
323 Released 2019-04-16
324
325 - Fix introspecting Python 3 functions by using varkw.
326 :pr:`101`
327 - Remove leftover files (``uwsgi.py``) in PyPI package. See issue
328 `#102` for more details.
329
330
331 Version 1.7.0
332 -------------
333
334 Released 2019-03-29
335
336 - Added a feature called 'response_filter' which enables one to only
337 cache views depending on the response code.
338 :pr:`99`
339 - A DeprecationWarning got turned into a TypeError.
340
341
342 Version 1.6.0
343 -------------
344
345 Released 2019-03-06
346
347 - The ``delete_many`` function is now able to ignore any errors and continue
348 deleting the cache. However, in order to preserve backwards compatibility,
349 the default mode is to abort the deletion process. In order to use the new
350 deletion mode, one has to flip the config setting ``CACHE_IGNORE_ERRORS`` to
351 ``True``. This was and still is only relevant for the **filesystem** and
352 **simple** cache backends.
353 :pr:`94`
354 - Re-added the ``gaememcached`` CACHE_TYPE for improved backwards compatibility.
355 - Documentation improvements
356
357
358 Version 1.5.0
359 -------------
360
361 Released 2019-02-23
362
363 - Add support for a Redis Sentinel Cluster.
364 :pr:`90`
365 - Parameterize the hash function so alternatives can be used.
366 :pr:`77`
367 - Include the deprecated ``werkzeug.contrib.cache`` module in Flask-Caching.
368 :pr:`75`
369
370
371 Version 1.4.0
372 -------------
373
374 Released 2018-04-16
375
376 - Fix logic for creating key for var args in memoize.
377 :pr:`70`
378 - Allow older Werkzeug versions by making the UWSGICache backend conditional.
379 :pr:`55`
380 - Some documentation improvements.
381 :pr:`48`,
382 `#51`,
383 `#56`,
384 `#67`
385 - Some CI improvements.
386 :pr:`49`,
387 `#50`
388
389
390 Version 1.3.3
391 -------------
392
393 Released 2017-06-25
394
395 - Add support for multiple query params and use md5 for consistent hashing.
396 :pr:`43`
397
398
399 Version 1.3.2
400 -------------
401
402 Released 2017-06-25
403
404 - Fix ``spreadsaslmemcached`` backend when using Python 3.
405 - Fix kwargs order when memoizing a function using Python 3.6 or greater.
406 See `#27`
407
408
409 Version 1.3.1
410 -------------
411
412 Released 2017-06-20
413
414 - Avoid breakage for environments with Werkzeug<0.12 installed because
415 the uwsgi backend depends on Werkzeug >=0.12. See `#38`
416
417
418 Version 1.3.0
419 -------------
420
421 Released 2017-06-17
422
423 - Add uWSGI Caching backend (requires Werkzeug >= 0.12)
424 - Provide a keyword `query_string` to the cached decorator in order to create
425 the same cache key for different query string requests,
426 so long as they have the same key/value (order does not matter).
427 :pr:`35`
428 - Use pytest as test suite and test runner. Additionally, the tests have
429 been split up into multiple files instead of having one big file.
430
431
432 Version 1.2.0
433 -------------
434
435 Released 2017-02-02
436
437 - Allows functions with kwargs to be memoized correctly. See `#18`
438
439
440 Version 1.1.1
441 -------------
442
443 Released 2016-12-09
444
445 - Fix PyPI Package distribution. See `#15`
446
447
448 Version 1.1.0
449 -------------
450
451 Released 2016-12-09
452
453 - Fix 'redis' backend import mechanisim. See `#14`
454 - Made backends a module to better control which cache backends to expose
455 and moved our custom clients into a own module inside of the backends
456 module. See also `#14` (and partly some own changes).
457 - Some docs and test changes. See `#8`
458 and `#12`
459
460
461 Version 1.0.1
462 -------------
463
464 Released 2016-08-30
465
466 - The caching wrappers like `add`, `set`, etc are now returning the wrapped
467 result as someone would expect. See `#5`
468
469
470 Version 1.0.0
471 -------------
472
473 Released 2016-07-05
474
475 - Changed the way of importing Flask-Cache. Instead of using the depreacted
476 method for importing Flask Extensions (via ``flask.ext.cache``),
477 the name of the extension, ``flask_cache`` is used. Have a look at
478 `Flask's documentation`
479 for more information regarding this matter. This also fixes the
480 deprecation warning from Flask.
481 - Lots of PEP8 and Documentation fixes.
482 - Renamed this fork Flask-Caching (``flask_caching``) as it will now be
483 available on PyPI for download.
484
485 In addition to the above mentioned fixes, following pull requests have been
486 merged into this fork of `Flask-Cache`:
487
488 - `#90 Update documentation: route decorator before cache`
489 - `#95 Pass the memoize parameters into unless().`
490 - `#109 wrapped function called twice`
491 - `#117 Moves setting the app attribute to the _set_cache method`
492 - `#121 fix doc for delete_memoized`
493 - `#122 Added proxy for werkzeug get_dict`
494 - `#123 "forced_update" option to 'cache' and 'memoize' decorators`
495 - `#124 Fix handling utf8 key args` (cherry-picked)
496 - `#125 Fix unittest failing for redis unittest`
497 - `#127 Improve doc for using @cached on view`
498 - `#128 Doc for delete_memoized`
499 - `#129 tries replacing inspect.getargspec with either signature or getfullargspec if possible`
500 - `make_cache_key() returning incorrect key` (cherry-picked)
501
502
503 Version 0.13
504 ------------
505
506 Released 2014-04-21
507
508 - Port to Python >= 3.3 (requiring Python 2.6/2.7 for 2.x).
509 - Fixed bug with using per-memoize timeouts greater than the default timeout
510 - Added better support for per-instance memoization.
511 - Various bug fixes
512
513
514 Version 0.12
515 ------------
516
517 Released 2013-04-29
518
519 - Changes jinja2 cache templates to use stable predictable keys. Previously
520 the key for a cache tag included the line number of the template, which made
521 it difficult to predict what the key would be outside of the application.
522 - Adds config variable `CACHE_NO_NULL_WARNING` to silence warning messages
523 when using 'null' cache as part of testing.
524 - Adds passthrough to clear entire cache backend.
525
526
527 Version 0.11.1
528 --------------
529
530 Released 2013-04-7
531
532 - Bugfix for using memoize on instance methods.
533 The previous key was id(self), the new key is repr(self)
534
535
536 Version 0.11
537 ------------
538
539 Released 2013-03-23
540
541 - Fail gracefully in production if cache backend raises an exception.
542 - Support for redis DB number
543 - Jinja2 templatetag cache now concats all args together into a single key
544 instead of treating each arg as a separate key name.
545 - Added delete memcache version hash function
546 - Support for multiple cache objects on a single app again.
547 - Added SpreadSASLMemcached, if a value is greater than the memcached threshold
548 which defaults to 1MB, this splits the value across multiple keys.
549 - Added support to use URL to connect to redis.
550
551
552 Version 0.10.1
553 --------------
554
555 Released 2013-01-13
556
557 - Added warning message when using cache type of 'null'
558 - Changed imports to relative instead of absolute for AppEngine compatibility
559
560
561 Version 0.10.0
562 --------------
563
564 Released 2013-01-05
565
566 - Added `saslmemcached` backend to support Memcached behind SASL authentication.
567 - Fixes a bug with memoize when the number of args != number of kwargs
568
569
570 Version 0.9.2
571 -------------
572
573 Released 2012-11-18
574
575 - Bugfix with default kwargs
576
577
578 Version 0.9.1
579 -------------
580
581 Released 2012-11-16
582
583 - Fixes broken memoized on functions that use default kwargs
584
585
586 Version 0.9.0
587 -------------
588
589 Released 2012-10-14
590
591 - Fixes memoization to work on methods.
592
593
594 Version 0.8.0
595 -------------
596
597 Released 2012-09-30
598
599 - Migrated to the new flask extension naming convention of flask_cache instead of flaskext.cache
600 - Removed unnecessary dependencies in setup.py file.
601 - Documentation updates
602
603
604 Version 0.7.0
605 -------------
606
607 Released 2012-08-25
608
609 - Allows multiple cache objects to be instantiated with different configuration values.
610
611
612 Version 0.6.0
613 -------------
614
615 Released 2012-08-12
616
617 - Memoization is now safer for multiple applications using the same backing store.
618 - Removed the explicit set of NullCache if the Flask app is set testing=True
619 - Swapped Conditional order for key_prefix
620
621
622 Version 0.5.0
623 -------------
624
625 Released 2012-02-03
626
627 - Deleting memoized functions now properly functions in production
628 environments where multiple instances of the application are running.
629 - get_memoized_names and get_memoized_keys have been removed.
630 - Added ``make_name`` to memoize, make_name is an optional callable that can be passed
631 to memoize to modify the cache_key that gets generated.
632 - Added ``unless`` to memoize, this is the same as the unless parameter in ``cached``
633 - memoization now converts all kwargs to positional arguments, this is so that
634 when a function is called multiple ways, it would evaluate to the same cache_key
635
636
637 Version 0.4.0
638 -------------
639
640 Released 2011-12-11
641
642 - Added attributes for uncached, make_cache_key, cache_timeout
643 to the decorated functions.
644
645
646 Version 0.3.4
647 -------------
648
649 Released 2011-09-10
650
651 - UTF-8 encoding of cache key
652 - key_prefix argument of the cached decorator now supports callables.
653
654
655 Version 0.3.3
656 -------------
657
658 Released 2011-06-03
659
660 Uses base64 for memoize caching. This fixes rare issues where the cache_key
661 was either a tuple or larger than the caching backend would be able to
662 support.
663
664 Adds support for deleting memoized caches optionally based on function parameters.
665
666 Python 2.5 compatibility, plus bugfix with string.format.
667
668 Added the ability to retrieve memoized function names or cache keys.
669
670
671 Version 0.3.2
672 -------------
673
674 Bugfix release. Fixes a bug that would cause an exception if no
675 ``CACHE_TYPE`` was supplied.
676
677 Version 0.3.1
678 -------------
679
680 Pypi egg fix.
681
682
683 Version 0.3
684 -----------
685
686 - CACHE_TYPE changed. Now one of ['null', 'simple', 'memcached',
687 'gaememcached', 'filesystem'], or an import string to a function that will
688 instantiate a cache object. This allows Flask-Cache to be much more
689 extensible and configurable.
690
691
692 Version 0.2
693 -----------
694
695 - CACHE_TYPE now uses an import_string.
696 - Added CACHE_OPTIONS and CACHE_ARGS configuration values.
697 - Added delete_memoized
698
699
700 Version 0.1
701 -----------
702
703 - Initial public release