{"id":48473609,"url":"https://github.com/kogan/django-lrucache-backend","last_synced_at":"2026-04-07T07:48:14.802Z","repository":{"id":57420708,"uuid":"97064734","full_name":"kogan/django-lrucache-backend","owner":"kogan","description":"A local in-memory cache backend for Django","archived":false,"fork":false,"pushed_at":"2023-10-06T00:15:07.000Z","size":314,"stargazers_count":42,"open_issues_count":0,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2026-04-07T07:48:12.595Z","etag":null,"topics":["cache","django","python","python3"],"latest_commit_sha":null,"homepage":"https://devblog.kogan.com/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kogan.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-13T00:57:29.000Z","updated_at":"2025-06-16T10:21:00.000Z","dependencies_parsed_at":"2024-06-21T15:20:39.638Z","dependency_job_id":"fbe1e89d-6035-4a53-95fd-78563e075432","html_url":"https://github.com/kogan/django-lrucache-backend","commit_stats":{"total_commits":22,"total_committers":2,"mean_commits":11.0,"dds":"0.045454545454545414","last_synced_commit":"d0b3434529fe52457f015c0c14829b21db15c957"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kogan/django-lrucache-backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kogan%2Fdjango-lrucache-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kogan%2Fdjango-lrucache-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kogan%2Fdjango-lrucache-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kogan%2Fdjango-lrucache-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kogan","download_url":"https://codeload.github.com/kogan/django-lrucache-backend/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kogan%2Fdjango-lrucache-backend/sbom","scorecard":{"id":565920,"data":{"date":"2025-08-11","repo":{"name":"github.com/kogan/django-lrucache-backend","commit":"dc2e3afdc759caa10abcc40874cd265063842b3b"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Code-Review","score":0,"reason":"Found 1/23 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 6 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Vulnerabilities","score":0,"reason":"42 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2014-5 / GHSA-296w-6qhq-gf92","Warn: Project is vulnerable to: PYSEC-2011-2 / GHSA-3jqw-crqj-w8qw","Warn: Project is vulnerable to: PYSEC-2012-3 / GHSA-59w8-4wm2-4xw8","Warn: Project is vulnerable to: PYSEC-2012-4 / GHSA-5h2q-4hrp-v9rr","Warn: Project is vulnerable to: PYSEC-2014-6 / GHSA-625g-gx8c-xcmg","Warn: Project is vulnerable to: PYSEC-2015-8 / GHSA-6565-fg86-6jcx","Warn: Project is vulnerable to: PYSEC-2021-98 / GHSA-68w8-qjq3-2gfm","Warn: Project is vulnerable to: PYSEC-2012-2 / GHSA-78vx-ggch-wghm","Warn: Project is vulnerable to: PYSEC-2015-9 / GHSA-7fq8-4pv5-5w5c","Warn: Project is vulnerable to: PYSEC-2015-4 / GHSA-7qfw-j7hp-v45g","Warn: Project is vulnerable to: PYSEC-2011-9 / GHSA-7wph-fc4w-wqp2","Warn: Project is vulnerable to: GHSA-7xr5-9hcq-chf9","Warn: Project is vulnerable to: PYSEC-2014-2 / GHSA-89hj-xfx5-7q66","Warn: Project is vulnerable to: GHSA-8x94-hmjh-97hq","Warn: Project is vulnerable to: PYSEC-2016-2 / GHSA-c8c8-9472-w52h","Warn: Project is vulnerable to: PYSEC-2016-3 / GHSA-crhm-qpjc-cm64","Warn: Project is vulnerable to: PYSEC-2014-4 / GHSA-f7cm-ccfp-3q4r","Warn: Project is vulnerable to: PYSEC-2016-16 / GHSA-fp6p-5xvw-m74f","Warn: Project is vulnerable to: PYSEC-2011-8 / GHSA-fwr5-q9rx-294f","Warn: Project is vulnerable to: PYSEC-2015-5 / GHSA-gv98-g628-m9x5","Warn: Project is vulnerable to: PYSEC-2015-20 / GHSA-h582-2pch-3xv3","Warn: Project is vulnerable to: PYSEC-2011-5 / GHSA-h95j-h2rv-qrg4","Warn: Project is vulnerable to: GHSA-hmr4-m2h5-33qx","Warn: Project is vulnerable to: PYSEC-2015-6 / GHSA-jhjg-w2cp-5j44","Warn: Project is vulnerable to: PYSEC-2016-15 / GHSA-pw27-w7w4-9qc7","Warn: Project is vulnerable to: PYSEC-2015-10 / GHSA-q5qw-4364-5hhm","Warn: Project is vulnerable to: PYSEC-2011-4 / GHSA-rm2j-x595-q9cj","Warn: Project is vulnerable to: GHSA-rrqc-c2jx-6jgv","Warn: Project is vulnerable to: PYSEC-2014-1 / GHSA-rvq6-mrpv-m6rm","Warn: Project is vulnerable to: PYSEC-2014-7 / GHSA-rw75-m7gp-92m3","Warn: Project is vulnerable to: PYSEC-2019-16 / GHSA-vfq6-hq5r-27r6","Warn: Project is vulnerable to: PYSEC-2014-3 / GHSA-wqjj-hx84-v449","Warn: Project is vulnerable to: PYSEC-2011-3 / GHSA-wxg3-mfph-qg9w","Warn: Project is vulnerable to: PYSEC-2011-1 / GHSA-x88j-93vc-wpmp","Warn: Project is vulnerable to: PYSEC-2007-1","Warn: Project is vulnerable to: PYSEC-2008-1","Warn: Project is vulnerable to: PYSEC-2008-2","Warn: Project is vulnerable to: PYSEC-2009-3","Warn: Project is vulnerable to: PYSEC-2015-11","Warn: Project is vulnerable to: PYSEC-2015-7","Warn: Project is vulnerable to: PYSEC-2016-18","Warn: Project is vulnerable to: PYSEC-2022-304"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T14:58:27.627Z","repository_id":57420708,"created_at":"2025-08-20T14:58:27.627Z","updated_at":"2025-08-20T14:58:27.627Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31504897,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T03:10:19.677Z","status":"ssl_error","status_checked_at":"2026-04-07T03:10:13.982Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache","django","python","python3"],"created_at":"2026-04-07T07:48:14.217Z","updated_at":"2026-04-07T07:48:14.792Z","avatar_url":"https://github.com/kogan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"django-lrucache-backend\n=======================\n\n.. image:: https://img.shields.io/pypi/v/django-lrucache-backend.svg\n    :target: https://pypi.python.org/pypi/django-lrucache-backend\n    :alt: Latest PyPI version\n\n.. image:: https://travis-ci.org/kogan/django-lrucache-backend.svg?branch=master\n   :target: https://travis-ci.org/kogan/django-lrucache-backend\n   :alt: Latest Travis CI build status\n\nA global object cache backend for Django.\n\n.. image:: https://github.com/kogan/django-lrucache-backend/blob/master/benchmarking/4.0.0/objects-get.png\n   :alt: Cache Performance\n\n`Set Performance \u003chttps://github.com/kogan/django-lrucache-backend/blob/master/benchmarking/4.0.0/objects-set.png\u003e`_.\n\n`Delete performance \u003chttps://github.com/kogan/django-lrucache-backend/blob/master/benchmarking/4.0.0/objects-delete.png\u003e`_.\n\nAbout\n-----\n\n`lrucache_backend` is an in-memory cache that has differing goals to the\n`LocMemCache` backend that Django provides.\n\nOriginally its purpose was to improve the cache eviction strategy, using an LRU\nalgorithm over a random cull. However, Django 2.1 changed the LocMemCache to also\nuse an LRU strategy.\n\nNow, `lrucache_backend` has two major differences from Django.\n\n1. Eliminates key char validation, improving performance at the cost of not\n   being portable with memcache backends.\n\n2. Eliminates serialization (pickling), allowing instances to be shared across\n   requests. Any mutations performed on cache objects are maintained.\n\n`lrucache_backend` functions as a global object cache, and uses a familiar Django\ninterface to avoid poorly reimplementing local object caches in service layers:\n\n.. code-block:: python\n\n    def get_data_before(self):\n        if not hasattr(self, '__data'):\n            self.__data = self.expensive_query()\n        return self.__data\n\n    def get_data_after(self):\n        lcache = caches['local']\n        data = lcache.get('our_data')\n        if not data:\n            data = self.expensive_query()\n            lcache.set('our_data', data, timeout=600)\n        return data\n\nThe benefits (despite the longer method) include timeouts, sharing data between\nrequests, and avoiding network requests. This is especially useful when there\nare hundreds or thousands of property accesses that would hit the cache where\nnetwork overhead would be prohibitive. The `Fat model` pattern can greatly\nbenefit from tiered caching.\n\nGood for?\n^^^^^^^^^\n\nAn in memory cache is good for small data that changes rarely. It's effectively\na global dictionary shared between requests in the same process. Small lookup\ntables and database backed settings are good candidates.\n\nA small number of keys should be used to avoid engaging the culling strategy\nof the cache. Performance goes down fast as soon as the maximum number of keys\nare reached, and keys start to evict.\n\nThis should **not** be used as your primary cache, but it makes for an\nexcellent secondary cache when you want to avoid the overhead of a network call.\n\nUse for:\n\n- Small lookup tables\n- Settings\n- Backing store for your service objects\n- Remembering values for the duration of a request or celery task\n- Small global template fragments like sidebars or footers\n- Secondary cache\n\nBad for?\n^^^^^^^^\n\nAn in memory cache is terrible for data that changes often. Because the cache\nis process local, it's extremely difficult to coordinate cache invalidation\nfrom external processes. For that reason, this library does nothing to support\ncache invalidation.\n\nThe cache shares memory with the application, so it's extremely important to\navoid storing a lot of keys, or any large values.\n\nDo **not** use for:\n\n- Instance attributes/properties\n- Full templates\n- Tables with a large number of rows\n- Large values\n- Large lists\n- Primary cache\n\nDifferences from LocMemCache\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n- Avoids pickling\n- Avoids key name validation\n\nInstallation\n------------\n\n.. code-block:: bash\n\n     pip install django-lrucache-backend\n\nRequirements\n^^^^^^^^^^^^\n\nThere are no longer any external dependencies. `lru-dict` used to be a dependency,\nbut as since been replaced with the built in `OrderedDict` as a consequence of\nnow deriving from the built in `LocMemCache`.\n\n\nUsage\n-----\n\nConfigure your `CACHES` Django setting appropriately:\n\n.. code-block:: python\n\n    CACHES = {\n        'local': {\n            'BACKEND': 'lrucache_backend.LRUObjectCache',\n            'TIMEOUT': 600,\n            'OPTIONS': {\n                'MAX_ENTRIES': 100,\n                'CULL_FREQUENCY': 100,\n            },\n            'NAME': 'optional-name'\n        }\n    }\n\nNote:\n    Set CULL_FREQUENCY == MAX_ENTRIES to only delete a single key per cull to\n    only eliminate a single entry per cull. This maintains the LRU property most\n    effectively, but can have performance implications.\n\nAnd then use the cache as you would any other:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e from django.core.cache import caches\n\n    \u003e\u003e\u003e local = caches['local']\n    \u003e\u003e\u003e local.set('key', 123)\n    \u003e\u003e\u003e local.get('key')\n    ... 123\n\nIf you're going to use this cache backend, then it's highly recommended to use\nit as a non-default cache. That is, do not configure this cache under the\n`default` name.\n\nLocal memory caches compete for memory with your application so it's in your\nbest interests to use it as sparingly and deliberately as possible.\n\nCompatibility\n-------------\n\nDjango 2.2+\nPython 3.6+\n\nLicence\n-------\n\nMIT\n\nAuthors\n-------\n\n`django-lrucache-backend` was written by `Josh Smeaton \u003cjosh.smeaton@gmail.com\u003e`_.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkogan%2Fdjango-lrucache-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkogan%2Fdjango-lrucache-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkogan%2Fdjango-lrucache-backend/lists"}