{ "info": { "author": "Josh Smeaton", "author_email": "josh.smeaton@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Framework :: Django", "Framework :: Django :: 1.11", "Framework :: Django :: 2.0", "Framework :: Django :: 2.1", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "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 smarter local memory cache backend for Django.\n\n.. image:: benchmarking/2.0.0/objects-get.png\n :alt: Cache Performance\n\n`Set Performance `_. `Delete performance\n`_.\n\nAbout\n-----\n\n`lrucache_backend` is an in-memory cache that improves upon the existing\n`LocMemCache` that Django provides.\n\nComes with cache timeouts and a smart eviction strategy that prefers to keep\nkeys that are used often and evict keys that are not.\n\nOriginally developed to avoid poorly reimplementing local object stores for\nservice layer objects. For example:\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- Uses an LRU eviction algorithm rather than a random percentage culling strategy\n\nInstallation\n------------\n\n.. code-block:: bash\n\n pip install django-lrucache-backend\n\nRequirements\n^^^^^^^^^^^^\n\n* `lru-dict `_.\n\n`lru-dict` is implemented in C and is unlikely to work with non-CPython\nimplementations. There *are* compatible pure python libraries. If you need this\nability, please open an Issue!\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 },\n 'NAME': 'optional-name'\n }\n }\n\nAnd then use the cache as you would any other:\n\n.. code-block:: python\n\n >>> from django.core.cache import caches\n\n >>> local = caches['local']\n >>> local.set('key', 123)\n >>> 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 1.11 - Django 2.2.\nPython support is 2.7 for Django 1.11, and 3.6+ for Django >= 2.0.\nPython 3.4 - 3.5 probably works with Django < 2.1, but is no longer tested.\n\nLicence\n-------\n\nMIT\n\nAuthors\n-------\n\n`django-lrucache-backend` was written by `Josh Smeaton `_.\n", "description_content_type": "text/x-rst", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/kogan/django-lrucache-backend", "keywords": "django,cache,lru", "license": "MIT", "maintainer": "Josh Smeaton", "maintainer_email": "josh.smeaton@gmail.com", "name": "django-lrucache-backend", "package_url": "https://pypi.org/project/django-lrucache-backend/", "platform": "", "project_url": "https://pypi.org/project/django-lrucache-backend/", "project_urls": { "Homepage": "https://github.com/kogan/django-lrucache-backend", "Repository": "https://github.com/kogan/django-lrucache-backend" }, "release_url": "https://pypi.org/project/django-lrucache-backend/2.0.0/", "requires_dist": [ "lru-dict (>=1.1,<2.0)", "Django (>=1.11,<2.0)" ], "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*", "summary": "A smarter local memory cache backend for Django", "version": "2.0.0" }, "last_serial": 4442855, "releases": { "0.2.0": [ { "comment_text": "", "digests": { "md5": "155a97cfc649a6ee5c36af9d25f2ea9a", "sha256": "d641c723c6722cab307977dc24a525e4e47ac7d4ff62a9063222260cb754849a" }, "downloads": -1, "filename": "django-lrucache-backend-0.2.0.tar.gz", "has_sig": true, "md5_digest": "155a97cfc649a6ee5c36af9d25f2ea9a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13035, "upload_time": "2017-07-16T08:32:24", "url": "https://files.pythonhosted.org/packages/55/99/98b89be65c87b3c0871c606f8c9a05f037b8214415e899a18f80a64e879e/django-lrucache-backend-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "9da5d105cb0dd39981b6cbdf092eb335", "sha256": "bbb1c3e61c270332ac6efb4c35e73099693e694fee961e33d420ae8eaf3110a8" }, "downloads": -1, "filename": "django-lrucache-backend-0.2.1.tar.gz", "has_sig": true, "md5_digest": "9da5d105cb0dd39981b6cbdf092eb335", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13026, "upload_time": "2017-07-16T08:38:18", "url": "https://files.pythonhosted.org/packages/95/d5/058f5ee49574c7ca366726f1b856ca9c38be6fa50759a0e35922820cfae4/django-lrucache-backend-0.2.1.tar.gz" } ], "2.0.0": [ { "comment_text": "", "digests": { "md5": "eb7e8a2cd70fcb9ddc88a7fe2ea2d9bc", "sha256": "1e3f9dead9651786e8b8e03f90864de777173530678cc78b137ed65456332168" }, "downloads": -1, "filename": "django_lrucache_backend-2.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "eb7e8a2cd70fcb9ddc88a7fe2ea2d9bc", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*", "size": 8864, "upload_time": "2018-11-02T00:46:09", "url": "https://files.pythonhosted.org/packages/20/08/6677c7cae79ef7f467a1335a89bc64c29d48e42c3b343174e1b5a0e7736b/django_lrucache_backend-2.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0e596da8c3eb0ac2e44cd5327df1e9ca", "sha256": "e67cfebbeccb9860911a8d3b3a047ca1b5e055c4ec708bef5f66ce45b2d4d779" }, "downloads": -1, "filename": "django-lrucache-backend-2.0.0.tar.gz", "has_sig": false, "md5_digest": "0e596da8c3eb0ac2e44cd5327df1e9ca", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*", "size": 5714, "upload_time": "2018-11-02T00:46:07", "url": "https://files.pythonhosted.org/packages/f5/78/7b18e554acfc7d42b6effbf0a9158dc35da7dfb0a2c30aa42c8eeba4e376/django-lrucache-backend-2.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "eb7e8a2cd70fcb9ddc88a7fe2ea2d9bc", "sha256": "1e3f9dead9651786e8b8e03f90864de777173530678cc78b137ed65456332168" }, "downloads": -1, "filename": "django_lrucache_backend-2.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "eb7e8a2cd70fcb9ddc88a7fe2ea2d9bc", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*", "size": 8864, "upload_time": "2018-11-02T00:46:09", "url": "https://files.pythonhosted.org/packages/20/08/6677c7cae79ef7f467a1335a89bc64c29d48e42c3b343174e1b5a0e7736b/django_lrucache_backend-2.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0e596da8c3eb0ac2e44cd5327df1e9ca", "sha256": "e67cfebbeccb9860911a8d3b3a047ca1b5e055c4ec708bef5f66ce45b2d4d779" }, "downloads": -1, "filename": "django-lrucache-backend-2.0.0.tar.gz", "has_sig": false, "md5_digest": "0e596da8c3eb0ac2e44cd5327df1e9ca", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*", "size": 5714, "upload_time": "2018-11-02T00:46:07", "url": "https://files.pythonhosted.org/packages/f5/78/7b18e554acfc7d42b6effbf0a9158dc35da7dfb0a2c30aa42c8eeba4e376/django-lrucache-backend-2.0.0.tar.gz" } ] }