{ "info": { "author": "Jan Nakladal", "author_email": "mojeto1@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.5" ], "description": "django-in-request-cache\n=======================\n\nDjango cache backend stored in django request \n\n.. image:: https://travis-ci.org/mojeto/django-in-request-cache.svg?branch=master&maxAge=259200\n :target: https://travis-ci.org/mojeto/django-in-request-cache\n\n.. image:: https://img.shields.io/pypi/v/django-in-request-cache.svg?maxAge=259200\n :target: https://pypi.python.org/pypi/django-in-request-cache\n\n.. image:: https://img.shields.io/pypi/l/django-in-request-cache.svg?maxAge=2592000\n :target: https://raw.githubusercontent.com/mojeto/django-in-request-cache/master/LICENSE\n\nInstallation\n------------\n\n.. code-block:: bash\n\n $ pip install django-in-request-cache\n\nFast InRequestCache\n-------------------\n\nInRequestCache is implementation of django cache interface.\nIt uses instance of python dict assigned to each django request object to store cached values.\n`django-globals`_ is used to make request object accessible everywhere.\nThis cache has the same limitations as standard django InMemory cache - Cross process access isn't possible.\nInRequestCache goes one step further and makes cross thread access impossible.\nInRequestCache is different in each request.\nInRequestCache should be faster than InMemory cache, because there is no read/write lock.\nIt makes sense to use InRequestCache for values which will be accessible multiple times in the same request.\nCache invalidation is hard, but because cache lives for request period only it isn't a big problem.\n\nQuick start\n-----------\n\n1. Add \"django-in-request-cache\" to your setting as cache like this::\n\n from django.conf.global_settings import CACHES as DEFAULT_CACHES\n\n CACHES = dict(\n DEFAULT_CACHES,\n cache_in_request={\n 'BACKEND': 'django_in_request_cache.cache.InRequestCache',\n # 'LOCATION': '_dinr_cache', # request property name to store data\n # 'OPTIONS': {\n # # if set then no value is stored for more than MAX_TIME time.\n # 'MAX_TIMEOUT': 10, # in seconds,\n # },\n },\n )\n\n2. Add django-globals middleware to your settings like this::\n\n MIDDLEWARE_CLASSES = [\n ...,\n 'django_globals.middleware.Global',\n ]\n\n\nSpeed up slower cache with faster cache\n---------------------------------------\n\nWhy do we want to cache a cache?\nIn my case I have one value in redis cache, which was accessed 20 times during the same django request.\nEvery read from redis takes ~1ms, it makes ~20ms just read the same value 20 times.\nTo speed it up I want cache my value in faster cache (InRequestCache, InMemoryCache etc.)\nCacheACache class is implementation of django cache interface which allows read value from slower cache\nonly once and 'cache' it again in faster in memory cache.\nMost of the time faster cache is back populated from slower cache. In this case we doesn't have information whe value expire.\nIn that case cache max expiration time for cached value is value expire time + slow cache expiration time.\nTherefore fast cache expiration time **should be set very low** (in number of seconds).\n\nCacheACache configuration\n-------------------------\n\n* How to cache a slower but cross process cache backend::\n\n from django.conf.global_settings import CACHES as DEFAULT_CACHES\n\n CACHES = dict(\n DEFAULT_CACHES,\n redis_cache = {\n 'BACKEND: 'redis_cache.RedisCache',\n ...\n },\n cache_in_request={\n 'BACKEND': 'django_in_request_cache.cache.InRequestCache',\n 'LOCATION': '_redis_cache_mirror', # request property name\n },\n combined_in_request_and_redis_cache={\n 'BACKEND': 'django_in_request_cache.cache.CacheACache',\n 'OPTIONS: {\n 'FAST_CACHE': 'cache_in_request', # cache alias\n 'FAST_CACHE_MAX_TIMEOUT': 5, # in seconds\n 'CACHE_TO_CACHE': 'redis_cache', # cache alias\n },\n },\n )\n\nRequirements\n------------\n\n* `Django`_ >= 1.6\n* `django-globals`_ >= 0.2\n\n\nLicense\n-------\n\n* `The MIT License`_\n\n.. _The MIT License: https://raw.githubusercontent.com/mojeto/django-in-request-cache/master/LICENSE\n.. _Django: https://github.com/django/django\n.. _django-globals: https://github.com/svetlyak40wt/django-globals", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mojeto/django-in-request-cache", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "django-in-request-cache", "package_url": "https://pypi.org/project/django-in-request-cache/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-in-request-cache/", "project_urls": { "Homepage": "https://github.com/mojeto/django-in-request-cache" }, "release_url": "https://pypi.org/project/django-in-request-cache/0.0.6/", "requires_dist": [ "Django (>=1.6)", "django-globals (>=0.2)" ], "requires_python": "", "summary": "Django cache backend stored in django request", "version": "0.0.6" }, "last_serial": 2345886, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "e2625163428d5aaeef4b0874ebd2a794", "sha256": "5a80aac73ed7af90b5923c05231a034dfdf7cde9751d8f069ddcd0f936aa1e35" }, "downloads": -1, "filename": "django-in-request-cache-0.0.1.tar.gz", "has_sig": false, "md5_digest": "e2625163428d5aaeef4b0874ebd2a794", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3090, "upload_time": "2016-07-06T09:07:26", "url": "https://files.pythonhosted.org/packages/a5/fd/ad20fbd49a5117b3ce679da1d2ca7d3a564fa99df652e4eb127f8391837a/django-in-request-cache-0.0.1.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "4c77be47478d6aa2a19bfb699f4efd2d", "sha256": "164a5d71d0ecec0d5752cfc9e631c5b4f2ea989798b6e91de8098cf371a83768" }, "downloads": -1, "filename": "django-in-request-cache-0.0.3.tar.gz", "has_sig": false, "md5_digest": "4c77be47478d6aa2a19bfb699f4efd2d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3076, "upload_time": "2016-07-06T09:17:32", "url": "https://files.pythonhosted.org/packages/33/94/b57daef73e0daec0f2844a70789ed9bbf712a48201c268e53b4c423ce4da/django-in-request-cache-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "c23821e385f2daba2434803a131b38c4", "sha256": "9fd491e5c82a45d2b737fe89031f06ba6af4411d2818adb277192d635d23c411" }, "downloads": -1, "filename": "django-in-request-cache-0.0.4.tar.gz", "has_sig": false, "md5_digest": "c23821e385f2daba2434803a131b38c4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4092, "upload_time": "2016-07-12T01:39:37", "url": "https://files.pythonhosted.org/packages/32/8e/56e9e6629f643cb129514a9dd4fdb97ff2e05ccf1e88d3b41d12bda8975e/django-in-request-cache-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "9e279f4b9f8b986f1e7fee59f290f3a4", "sha256": "9731ef13a0526bc876e5d6a21de0a17210d36313dc3b2a104bdd27a0e0105e31" }, "downloads": -1, "filename": "django_in_request_cache-0.0.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "9e279f4b9f8b986f1e7fee59f290f3a4", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8588, "upload_time": "2016-09-16T09:00:23", "url": "https://files.pythonhosted.org/packages/e1/4a/3194c3cd976943bdf7d6d750881ed90403da00367111abcd4fa62e12199f/django_in_request_cache-0.0.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cfb5cc2616d59e8dacd9fafa87be22e9", "sha256": "307823696c73f8c4d735ec6ee76b0145316a4edd7d30b44fb892aa917b51abd2" }, "downloads": -1, "filename": "django-in-request-cache-0.0.5.tar.gz", "has_sig": false, "md5_digest": "cfb5cc2616d59e8dacd9fafa87be22e9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5648, "upload_time": "2016-09-16T08:24:05", "url": "https://files.pythonhosted.org/packages/bf/ba/e07b936a864e29227948828e8fce75d23065f75e1e88ee5dc25b7ca72fb1/django-in-request-cache-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "15ee4311351439b05fc3a01688e4e6cd", "sha256": "8f9ac541cbc5a7efbe59a8ec265d139bd0ad5d36a8efbf6a739c02041ea6f3c6" }, "downloads": -1, "filename": "django_in_request_cache-0.0.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "15ee4311351439b05fc3a01688e4e6cd", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8631, "upload_time": "2016-09-16T09:25:34", "url": "https://files.pythonhosted.org/packages/cf/d7/5887c077ef7150026a3a574cb6049900ac2403722e7308c446cd3a89d148/django_in_request_cache-0.0.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5f0c91b36be793a9e6dce0fd898e9e00", "sha256": "447c0c8278aa88c9c9e9a8ff86b4d2d277b78b81a3b2bd7bd91e3d6418968aac" }, "downloads": -1, "filename": "django-in-request-cache-0.0.6.tar.gz", "has_sig": false, "md5_digest": "5f0c91b36be793a9e6dce0fd898e9e00", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5814, "upload_time": "2016-09-16T09:25:37", "url": "https://files.pythonhosted.org/packages/c0/a9/b5c90e5182239709db06a8fa9f674a55ad9059404cd1bad891636e08da36/django-in-request-cache-0.0.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "15ee4311351439b05fc3a01688e4e6cd", "sha256": "8f9ac541cbc5a7efbe59a8ec265d139bd0ad5d36a8efbf6a739c02041ea6f3c6" }, "downloads": -1, "filename": "django_in_request_cache-0.0.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "15ee4311351439b05fc3a01688e4e6cd", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8631, "upload_time": "2016-09-16T09:25:34", "url": "https://files.pythonhosted.org/packages/cf/d7/5887c077ef7150026a3a574cb6049900ac2403722e7308c446cd3a89d148/django_in_request_cache-0.0.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5f0c91b36be793a9e6dce0fd898e9e00", "sha256": "447c0c8278aa88c9c9e9a8ff86b4d2d277b78b81a3b2bd7bd91e3d6418968aac" }, "downloads": -1, "filename": "django-in-request-cache-0.0.6.tar.gz", "has_sig": false, "md5_digest": "5f0c91b36be793a9e6dce0fd898e9e00", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5814, "upload_time": "2016-09-16T09:25:37", "url": "https://files.pythonhosted.org/packages/c0/a9/b5c90e5182239709db06a8fa9f674a55ad9059404cd1bad891636e08da36/django-in-request-cache-0.0.6.tar.gz" } ] }