summaryrefslogtreecommitdiff
path: root/django/core/cache/backends/locmem.py
AgeCommit message (Collapse)Author
2025-03-01Applied Black's 2025 stable style.Mariusz Felisiak
https://github.com/psf/black/releases/tag/25.1.0
2021-09-07Fixed #33060 -- Added BaseCache.make_and_validate_key() hook.Nick Pope
This helper function reduces the amount of duplicated code and makes it easier to ensure that we always validate the keys.
2020-08-24Fixed #31907 -- Fixed missing validate_key() calls in cache backends.Nick Pope
2019-11-14Fixed #30759 -- Made cache.delete() return whether it succeeded.daniel a rios
Thanks Simon Charette for the review.
2018-07-09Fixed #29550 -- Eased overriding pickle.dumps() protocol in cache backends ↵Simon Charette
and session serializer.
2018-04-27Fixed #27480 -- Added cache.touch().Nicolas Noé
2018-01-24Fixed #28977 -- Changed local-memory cache to use LRU culling.Grant Jenks
LRU culling turns every read into a kind of write to the cache: cache keys are moved to the first position in the OrderedDict when they are retrieved. The RWLock which permitted multiple readers while prioritizing a single writer is obsolete since all accesses are now writes.
2018-01-03Fixed #28982 -- Simplified code with and/or.Дилян Палаузов
2017-12-07Refs #23919 -- Replaced super() calls for old-style classes.Nick Pope
2017-09-07Reverted "Fixed #27818 -- Replaced try/except/pass with contextlib.suppress()."Tim Graham
This reverts commit 550cb3a365dee4edfdd1563224d5304de2a57fda because try/except performs better.
2017-06-28Fixed #27818 -- Replaced try/except/pass with contextlib.suppress().Mads Jensen
2017-01-18Refs #23919 -- Removed most of remaining six usageClaude Paroz
Thanks Tim Graham for the review.
2015-02-06Sorted imports with isort; refs #23860.Tim Graham
2014-10-12Fixed #23642 -- Made LocMemCache.incr() thread-safe as documentedThomas Chaumeny
2014-10-10Fixed #23625 -- Removed CacheClass shimJaap Roes
2014-05-09Fixed #22606 -- Locmemcache has_key() failed for infinite cache expiryMalcolm Box
Refactored cache expiry logic for Locmemcache to make consistent across all places where accessed, and correctly handle None as expiry time.
2014-04-23Fixed #22495 -- Locmem cache.add() failed with infinite timeoutsMalcolm Box
cache.add() incorrectly succeeded when there was an existing key with an infinite (None) timeout.
2013-11-23Follow up to e112654fc81ddb3fbffbb8382b004d69367a85feFlorian Apolloner
Actually comitted the code now :þ
2013-10-01Fixed #21147 -- Avoided time.time precision issue with cache backends.Michael Manfre
The precision of time.time() is OS specific and it is possible for the resolution to be low enough to allow reading a cache key previously set with a timeout of 0.
2013-07-08A few cleanups to capture the minimum amount of code in try/except blocks.Alex Gaynor
2013-07-06Fixed 20613 - moved pickle loads/dumps outside with ↵ersran9
self._lock.reader()/writer() blocks Additionaly added pickled=None initially and check for none before returning in get
2013-05-18Fixed #9595 -- Allow non-expiring cache timeouts.Jacob Burch
Also, streamline the use of 0 and None between cache backends.
2012-07-22[py3] Switched to Python 3-compatible imports.Aymeric Augustin
xrange/range will be dealt with in a separate commit due to the huge number of changes.
2012-03-30Removed with_statement imports, useless in Python >= 2.6. Refs #17965. ↵Claude Paroz
Thanks jonash for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17828 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-11-27Clean up the the locmem cache backend and utils.synch by using context ↵Alex Gaynor
managers. Puch prettier. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17152 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-11-26Fixed #17287 -- Prevented LocMemCache.incr/decr from changing key expiry ↵Carl Meyer
time. Thanks Ivan Virabyan for report and patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17151 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-11-21Fixed #16378. Locmem now uses pickle.HIGHEST_PROTOCOL for better ↵Paul McMillan
compatibility with other hash backends. Thanks aaugustin for the initial patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17136 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-03-28Removed a bunch of Python 2.4 workarounds now that we don't support it. Refs ↵Adrian Holovaty
#15702 -- thanks to jonash for the patch. Splitting this over muliple commits to make it more manageable. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15926 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-12-21Fixed #11675 -- Added support for the PyLibMC cache library. In order to ↵Russell Keith-Magee
support this, and clean up some other 1.3 caching additions, this patch also includes some changes to the way caches are defined. This means you can now have multiple caches, in the same way you have multiple databases. A huge thanks to Jacob Burch for the work on the PyLibMC backend, and to Jannis for his work on the cache definition changes. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15005 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-11-19Fixed #13795 -- Added a site-wide cache prefix and cache versioning. Thanks ↵Russell Keith-Magee
to bruth for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14623 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-11-02Fixed #14596 -- Light refactoring of the cache backends.Russell Keith-Magee
* Removes some code duplication, * Provides a convenient base class for db-like cache backends * Adds tests for an edge case of culling, * Marks the memcached tests as "skipped", rather than omitting them. Thanks to Jonas H for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14434 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-09-12Add warning when using cache keys that might not work with memcached.Malcolm Tredinnick
This means testing with local dev caches (not memcache) will warn developers if they are introducing inadvertent importabilities. There is also the ability to silence the warning if a dev is not planning to use memcache and knows what they are doing with their keys. Thanks to Carl Meyer for the patch. Fixed #6447. git-svn-id: http://code.djangoproject.com/svn/django/trunk@13766 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-05-04Fixed #12164 -- Removed the Python 2.3 compatibility imports and ↵Russell Keith-Magee
workarounds. Thanks to timo and claudep for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@13094 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2010-01-27Fixed #12671 -- Added set_many(), get_many(), and clear() methods to the ↵Russell Keith-Magee
cache backend interface. Thanks to Jeff Balogh for the report and patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12306 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-04-01Fixed #9644: fix a thread sync issue in the locmem cache. Thanks, mrts.Jacob Kaplan-Moss
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10333 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2009-03-08Fixed #9626 -- Fixed a deletion race in the locmem cache.Malcolm Tredinnick
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9998 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-08-10Added a return value to the add() method for caches. It's now possible to tellMalcolm Tredinnick
if a call to add() ended up storing something in the cache. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8278 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2008-07-26Fixed #6413 -- Fixed a deadlock situation in the locmem culling implementation.Malcolm Tredinnick
Thanks, Joe Holloway. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8090 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-12-11Fixe #6131 -- Fixed a problem with expired keys in the locmem cache. Based ↵Malcolm Tredinnick
on a patch from sherbang. In passing, changed the get() method to use a similar style to has_key() and made add() fractionally faster with the same sort of change (only compute time.time() when we really need it). git-svn-id: http://code.djangoproject.com/svn/django/trunk@6904 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-12-02Fixed #6086 -- Deprecate the "simple" cache backend in favour of "locmem".Malcolm Tredinnick
Thanks, Paul Bissex. git-svn-id: http://code.djangoproject.com/svn/django/trunk@6822 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-11-21Fixed #5981 -- Fixed failing regression test when using locmem cache ↵Gary Wilson Jr
backend. Changed `add` to pickle the value as is done in `set`. Based on patch from mattmcc. git-svn-id: http://code.djangoproject.com/svn/django/trunk@6709 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-10-20Fixed #4831 -- Added an "add" cache key method, for parity with memcached'sMalcolm Tredinnick
API. This works for all cache backends. Patch from Matt McClanahan. git-svn-id: http://code.djangoproject.com/svn/django/trunk@6572 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-15Changed imports to adhere to PEP 8.Gary Wilson Jr
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5704 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-15Fixed #3012 -- Changed the locmem cache backend to use pickle instead of ↵Gary Wilson Jr
deepcopy to make it compatible with iterators (which cannot be copied). Patch from Sundance. git-svn-id: http://code.djangoproject.com/svn/django/trunk@5703 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2006-07-21Fixed a bunch of spurious imports, typos, and other small errors turned up ↵Jacob Kaplan-Moss
by a pass through PyFlakes. This covers about the first third of the errors. git-svn-id: http://code.djangoproject.com/svn/django/trunk@3411 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2006-02-24Refactored cache from django/core/cache.py into django/core/cache package, ↵Adrian Holovaty
with each backend getting a separate module. This keeps things cleaner and uses less memory, because the backend module is only loaded if it's needed. git-svn-id: http://code.djangoproject.com/svn/django/trunk@2378 bcc190cf-cafb-0310-a4f2-bffc1f526a37