{ "info": { "author": "Mikhail Korobov", "author_email": "kmike84@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "===================\ndjango-cache-utils2\n===================\n\ndjango-cache-utils2 provides ``cached`` decorator and ``invalidate`` function.\n\nInstallation\n============\n\n::\n\n pip install django-cache-utils2\n\nUsage\n=====\n\n::\n\n from cache_utils2 import cached, invalidate\n\n @cached(60)\n def foo(x, y=0):\n print 'foo is called'\n return x+y\n\n foo(1, 2) # foo is called\n foo(1, y=2)\n foo(5, 6) # foo is called\n foo(5, 6)\n invalidate(foo, {'x': 1, 'y': 2})\n foo(1, 2) # foo is called\n foo(5, 6)\n foo(x=2) # foo is called\n foo(x=2)\n\n class Foo(object):\n @cached(60)\n def foo(self, x, y):\n print \"foo is called\"\n return x+y\n\n obj = Foo()\n obj.foo(1,2) # foo is called\n obj.foo(1,2)\n\n invalidate(Foo.foo, {'x': 1, 'y': 2})\n obj.foo(1,2) # foo is called\n\n\n\nDjango example\n--------------\n\n::\n\n from django.db import models\n from cache_utils2 import cached, invalidate\n\n class CityManager(models.Manager):\n\n # cache a method result. 'self' parameter is ignored\n @cached(60*60*24)\n def default(self):\n return self.active()[0]\n\n # cache a method result. 'self' parameter is ignored, args and\n # kwargs are used to construct the cache key\n @cached(60*60*24)\n def get(self, *args, **kwargs):\n return super(CityManager, self).get(*args, **kwargs)\n\n\n class City(models.Model):\n # ... field declarations\n\n objects = CityManager()\n\n # cache django model instance method result by instance pk\n @cached(30, vary='self.pk')\n def has_offers(self):\n return self.offer_set.count() > 0\n\n # invalidation of model methods\n invalidate(City.has_offers, {'self.pk': 1}\n\n\nNotes\n=====\n\nIf decorated function returns ``cache_utils2.NO_CACHE`` cache will be bypassed.\n\n\nRunning tests\n=============\n\nGet the source code and run ``runtests.py``.", "description_content_type": null, "docs_url": null, "download_url": "http://bitbucket.org/kmike/django-cache-utils2/get/tip.zip", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://bitbucket.org/kmike/django-cache-utils2/", "keywords": null, "license": "MIT license", "maintainer": null, "maintainer_email": null, "name": "django-cache-utils2", "package_url": "https://pypi.org/project/django-cache-utils2/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-cache-utils2/", "project_urls": { "Download": "http://bitbucket.org/kmike/django-cache-utils2/get/tip.zip", "Homepage": "http://bitbucket.org/kmike/django-cache-utils2/" }, "release_url": "https://pypi.org/project/django-cache-utils2/0.1/", "requires_dist": null, "requires_python": null, "summary": "Django caching decorator + invalidate function", "version": "0.1" }, "last_serial": 654361, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "55618448c0fbab7d1a356dcb3a947cf2", "sha256": "8b6efe29f7b7428aec54460e07fde214f6ac12f852e766e53dd6723a68600e8c" }, "downloads": -1, "filename": "django-cache-utils2-0.1.tar.gz", "has_sig": false, "md5_digest": "55618448c0fbab7d1a356dcb3a947cf2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5244, "upload_time": "2011-11-05T08:53:08", "url": "https://files.pythonhosted.org/packages/1f/b7/4c30b4da63883504f7cce16d293426b83a0c010ef3c9592fd63a310574ca/django-cache-utils2-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "55618448c0fbab7d1a356dcb3a947cf2", "sha256": "8b6efe29f7b7428aec54460e07fde214f6ac12f852e766e53dd6723a68600e8c" }, "downloads": -1, "filename": "django-cache-utils2-0.1.tar.gz", "has_sig": false, "md5_digest": "55618448c0fbab7d1a356dcb3a947cf2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5244, "upload_time": "2011-11-05T08:53:08", "url": "https://files.pythonhosted.org/packages/1f/b7/4c30b4da63883504f7cce16d293426b83a0c010ef3c9592fd63a310574ca/django-cache-utils2-0.1.tar.gz" } ] }