{ "info": { "author": "Matthew Dapena-Tretter", "author_email": "m@tthewwithanm.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP" ], "description": "Features\n========\n\n- Graceful handling of errors (can fall back to cached value)\n- Calculate results in background (requires Celery_)\n- Readable duration strings (`'1 day'` vs `86400`)\n- Correct handling of `None`\n- Per-call invalidation\n\n\nInstallation\n============\n\n1. `pip install django-throttleandcache`\n2. Set a cache backend in your `settings.py` file.\n\n\nUsage\n=====\n\n.. code-block:: python\n\n from throttleandcache import cache\n\n # Cache the result of my_function for 3 seconds.\n @cache('3s')\n def my_function():\n return 'whatever'\n\nIf you call the function multiple times *with the same arguments*, the result\nwill be fetched from the cache. In order to invalidate the cache for that call,\ncall `my_function.invalidate()` with the same arguments:\n\n.. code-block:: python\n\n my_function()\n my_function() # Result pulled from cache\n my_function.invalidate()\n my_function() # Not from cache\n\nIf Celery_ is installed, you can remove the the calculation of new values from\nthe request/response cycle:\n\n.. code-block:: python\n\n @cache('3s', background=True)\n def my_function():\n return 'whatever'\n\nNote that, in the case of a cold cache, the value will still be calculated\nsynchronously. Stale values may be used while new ones are being calculated.\n\nRemember that calling the same method on multiple instances means that each\ninvocation will have a different first positional (`self`) argument:\n\n.. code-block:: python\n\n class A(object):\n @cache('100s')\n def my_function(self):\n print 'The method is being executed!'\n\n instance_1 = A()\n instance_2 = A()\n instance_1.my_function() # The original method will be invoked\n instance_2.my_function() # Different \"self\" argument, so the method is invoked again.\n\nIf you wish to cache the result across all instances, use `@cacheforclass`.\n\nThe first argument to the `cache` decorator is the timeout and can be given as\na number (of seconds) or a string. Since strings contain units, they can make\nyour code much more readable. Some examples are `'2s'`, `'3m'`, `'3m 2s'`, and\n`'3 minutes, 2 seconds'`.\n\nThe `cache` decorator also accepts the following (optional) keyword arguments:\n\n- **using**: specifies which cache to use.\n- **key_prefix**: A string to prefix your cache key with.\n- **key_func**: A function for deriving the cache key. This function will be\n passed the ``fn``, ``*args``, and ``**kwargs``.\n- **graceful**: This argument specifies how errors should be handled. If\n `graceful` is `True` and your function raises an error, throttleandcache\n will log the error and return the cached value. If no cached value exists,\n the original error is raised.\n- **background**: Specifies that new values should be calculated in the\n background (using Celery_).\n\n\n.. _Celery: http://www.celeryproject.org/", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/matthewwithanm/django-throttleandcache", "keywords": null, "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "django-throttleandcache", "package_url": "https://pypi.org/project/django-throttleandcache/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-throttleandcache/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/matthewwithanm/django-throttleandcache" }, "release_url": "https://pypi.org/project/django-throttleandcache/2.1.0/", "requires_dist": null, "requires_python": null, "summary": "A utility for caching/throttling function calls.", "version": "2.1.0" }, "last_serial": 1437714, "releases": { "1.0b1": [ { "comment_text": "", "digests": { "md5": "5865ba29bf505e12e8f968a000346099", "sha256": "f44af06330b4efad57c55f80a7064ad0fb219f11cdda56809fe336e3d907f236" }, "downloads": -1, "filename": "django-throttleandcache-1.0b1.tar.gz", "has_sig": false, "md5_digest": "5865ba29bf505e12e8f968a000346099", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5501, "upload_time": "2013-06-15T01:04:04", "url": "https://files.pythonhosted.org/packages/61/47/9c1c1b8eec587aa531d0a7a268e2d75af72303828fac23164946cda05a0f/django-throttleandcache-1.0b1.tar.gz" } ], "1.0b2": [ { "comment_text": "", "digests": { "md5": "8f30cf0ad0002b8f3753cc312071fda4", "sha256": "91c7ef27dcf343c67a4371952afec8c5989df3f7a88d05efbb7f10df8d3fed2b" }, "downloads": -1, "filename": "django-throttleandcache-1.0b2.tar.gz", "has_sig": false, "md5_digest": "8f30cf0ad0002b8f3753cc312071fda4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5638, "upload_time": "2013-07-03T15:59:32", "url": "https://files.pythonhosted.org/packages/8c/fb/3e785d0587730041a6cbb0287c8cae2e1f4830ead958125745703e456f0c/django-throttleandcache-1.0b2.tar.gz" } ], "1.0b3": [ { "comment_text": "", "digests": { "md5": "c27dc3d1fa4486e1894e8c89e2eb86a2", "sha256": "00e39b13ccd59aaef9f6208c74da2afa093f7e30274d2d42a9ef8fe027c221ee" }, "downloads": -1, "filename": "django-throttleandcache-1.0b3.tar.gz", "has_sig": false, "md5_digest": "c27dc3d1fa4486e1894e8c89e2eb86a2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5890, "upload_time": "2013-07-03T19:51:21", "url": "https://files.pythonhosted.org/packages/13/f9/b9c7757aa2d3d7e6cb0bffad2939598af9d1e3be05cbd4e7c8c61c6d5642/django-throttleandcache-1.0b3.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "bc0ee83f16b3a78438b712cb94f28a4c", "sha256": "e7c55a7b27597fe8850f211b0735982d900cb156b80a111e7576bd29ee8d5fec" }, "downloads": -1, "filename": "django-throttleandcache-1.1.0.tar.gz", "has_sig": false, "md5_digest": "bc0ee83f16b3a78438b712cb94f28a4c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6171, "upload_time": "2014-08-20T21:13:11", "url": "https://files.pythonhosted.org/packages/c3/c4/0ea028f93eb8e910deb09e07086a7f6382b8a70c86fc2aa0a6cbf99eec32/django-throttleandcache-1.1.0.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "0b2c1dda861c8f1e11b7ba18b5f11a44", "sha256": "8401e48ee1eea5ab5e47eae197067a289b9ff37c3130d07d7db6fc516fa8513d" }, "downloads": -1, "filename": "django-throttleandcache-1.2.0.tar.gz", "has_sig": false, "md5_digest": "0b2c1dda861c8f1e11b7ba18b5f11a44", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6432, "upload_time": "2015-01-20T22:24:13", "url": "https://files.pythonhosted.org/packages/d4/de/1bb729b5fb163c8e3bbc0224d97e0772040a7ec2b5fb6c4c252f86dce23f/django-throttleandcache-1.2.0.tar.gz" } ], "2.0.0": [ { "comment_text": "", "digests": { "md5": "d2500d67932c79b24115d09f208d697e", "sha256": "4d1a5415c9323d3a9f335b5c8bfc00193d38ad760a6c984bc7ba1f52d61394df" }, "downloads": -1, "filename": "django-throttleandcache-2.0.0.tar.gz", "has_sig": false, "md5_digest": "d2500d67932c79b24115d09f208d697e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7422, "upload_time": "2015-01-22T15:19:28", "url": "https://files.pythonhosted.org/packages/cc/c2/ca201d525095f0cb2e7ccdf5a4d5e43d3387a21666abeeb8566e24cde474/django-throttleandcache-2.0.0.tar.gz" } ], "2.0.1": [ { "comment_text": "", "digests": { "md5": "473f6a2c8248e57ff7611da492474f76", "sha256": "535ac6cd68c43c3deecbe2d841edad53c9574466d7f822fc02ff33ee68985e73" }, "downloads": -1, "filename": "django-throttleandcache-2.0.1.tar.gz", "has_sig": false, "md5_digest": "473f6a2c8248e57ff7611da492474f76", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7701, "upload_time": "2015-02-17T16:19:53", "url": "https://files.pythonhosted.org/packages/5b/d8/ecf061e90d305e830246267dde941d911b9cc047e314488fa28b2bee738f/django-throttleandcache-2.0.1.tar.gz" } ], "2.0.2": [ { "comment_text": "", "digests": { "md5": "f867a603bd0c57ac90b29d3f34248fca", "sha256": "b13a3d387ca210427952f1d66e51d4a06b7cd0c8e7286dae58a812d284987e9a" }, "downloads": -1, "filename": "django-throttleandcache-2.0.2.tar.gz", "has_sig": false, "md5_digest": "f867a603bd0c57ac90b29d3f34248fca", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7913, "upload_time": "2015-02-24T21:33:29", "url": "https://files.pythonhosted.org/packages/46/1d/cb4a661a1025bbe6b618a7809daea8e9da1f0c87e41a8ca120c236928bae/django-throttleandcache-2.0.2.tar.gz" } ], "2.1.0": [ { "comment_text": "", "digests": { "md5": "d468f077b04a7181e0b1a0fb1e55a0ec", "sha256": "9b67befe3d05f5b5c434c7d4b38f0abe75d034a93a47edbc752d08fc397587bf" }, "downloads": -1, "filename": "django-throttleandcache-2.1.0.tar.gz", "has_sig": false, "md5_digest": "d468f077b04a7181e0b1a0fb1e55a0ec", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7901, "upload_time": "2015-02-25T15:56:20", "url": "https://files.pythonhosted.org/packages/02/b2/f98913e85acd85a4581f9a5e21ebc93afdcc757fd032d393de2f4a11d26a/django-throttleandcache-2.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d468f077b04a7181e0b1a0fb1e55a0ec", "sha256": "9b67befe3d05f5b5c434c7d4b38f0abe75d034a93a47edbc752d08fc397587bf" }, "downloads": -1, "filename": "django-throttleandcache-2.1.0.tar.gz", "has_sig": false, "md5_digest": "d468f077b04a7181e0b1a0fb1e55a0ec", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7901, "upload_time": "2015-02-25T15:56:20", "url": "https://files.pythonhosted.org/packages/02/b2/f98913e85acd85a4581f9a5e21ebc93afdcc757fd032d393de2f4a11d26a/django-throttleandcache-2.1.0.tar.gz" } ] }