{ "info": { "author": "Douglas Farinelli", "author_email": "douglas.farinelli@gmail.com", "bugtrack_url": null, "classifiers": [ "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6" ], "description": "python-cachelock\n================\n\n[![Supported Versions](https://img.shields.io/pypi/pyversions/cachelock.svg)](https://pypi.python.org/pypi/cachelock)\n[![Build Status](https://travis-ci.org/douglasfarinelli/python-cachelock.svg?branch=master)](https://travis-ci.org/douglasfarinelli/python-cachelock)\n[![Coverage Status](https://coveralls.io/repos/github/douglasfarinelli/python-cachelock/badge.svg?branch=master)](https://coveralls.io/github/douglasfarinelli/python-cachelock?branch=master)\n[![PyPI version](https://badge.fury.io/py/cachelock.svg)](https://pypi.python.org/pypi/cachelock)\n\nThe `cachelock` serves to ensure that your code block or function is executed one at a time using the cache as acquirer.\n\nHow to install:\n===============\n\n pip install cachelock\n\nor\n\n pipenv install cachelock\n \nHow to use\n==========\n\nYou can use of two forms:\n\n - Use the `Lock` class to your blocks;\n - Or use the decorator `once` to block your functions or tasks;\n\nWith cachelock.Lock\n===================\n\nArguments:\n\n with cachelock.Lock(\n key=...\n cache=...,\n ) ...\n\nYou should use the Lock class as with context:\n\n with cachelock.Lock(key='foo'):\n ...your code ...\n\nIf it is already locked, the LockError will be raised.\n\nWith cachelock.once\n===================\n\nArguments:\n\n @cachelock.once(\n key=...\n cache=...,\n raises_if_lock=False\n )\n ...\n\nWith the decorator, you can guarantee the unique execution of some function. It also allows you to configure your key according to the arguments of the function.\n\n @celery.task\n @cachelock.once(key='foo-{arg_a}-{arg_b}')\n def func(arg_a, arg_b):\n pass\n\nThat way, if it is locked, the function quits silently. You can also ask `once` to raise `LockError`:\n\n @celery.task\n @cachelock.once(\n key='foo-{arg_a}-{arg_b}',\n raise_if_lock=True\n )\n def func(arg_a, arg_b):\n pass\n\nIntegrate with Django\n=====================\n\nThe cachelock checks whether django is installed, and if so, it uses django's own cache as aquirer. And if you wish, you can modify the default cache with `DEFAULT_CACHELOCK_ALIAS` configuration through django settings. The value must be an alias of some existing cache, by default it uses `default`\n\n\n*Remembering that by `default`, `cachelock` uses its own internal cache in memory if there is no integration with `django`.*\n\nCustomizing your own cache\n==========================\n\nTo work it is necessary that the implementation of the cache has the `get`, `delete` and `set` methods. Ex.:\n\n class DummyCache:\n\n def set(self, key, value):\n pass\n\n def get(self, key, default=None):\n pass\n\n def delete(self, key):\n pass\n\n cache = DummyCache()\n\nuse: \n\n @cachelock.once(key=..., cache=cache)\n \nor\n \n with cachelock.Lock(key..., cache=cache) ...\n ", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/douglasfarinelli/python-cachelock", "keywords": "lock cache once celery tasks single-execution", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "cachelock", "package_url": "https://pypi.org/project/cachelock/", "platform": "any", "project_url": "https://pypi.org/project/cachelock/", "project_urls": { "Homepage": "https://github.com/douglasfarinelli/python-cachelock" }, "release_url": "https://pypi.org/project/cachelock/0.0.3/", "requires_dist": null, "requires_python": "", "summary": "A simple look that uses the cache as acquirer", "version": "0.0.3" }, "last_serial": 3550218, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "efcea2050e19f70b69c1b30afed9d511", "sha256": "7e84f15ee794453e2cf574a0871cd38e8b2d1d5b6fb55036770901c9e3d372dd" }, "downloads": -1, "filename": "cachelock-0.0.1.tar.gz", "has_sig": false, "md5_digest": "efcea2050e19f70b69c1b30afed9d511", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4036, "upload_time": "2018-01-27T01:35:24", "url": "https://files.pythonhosted.org/packages/62/b5/0283c66abc4c8e75dbe5514b15daf371f70c69f4c625cd4132d5559fcb97/cachelock-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "345cae66aa95717b05ad18213cd43096", "sha256": "0108fc553edd446739602e2661004d1409b87af7c37106b79e10219ff81a7847" }, "downloads": -1, "filename": "cachelock-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "345cae66aa95717b05ad18213cd43096", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 6257, "upload_time": "2018-02-04T12:36:57", "url": "https://files.pythonhosted.org/packages/6e/86/e61485ef64b3d12ce0e0e38e19e7594674a228ee697b61e77bca0f3da264/cachelock-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3c0eedefd6b77ac4a16eee494356ab97", "sha256": "f9325a8fcb447299918d0df25c97b523a7e7143a7a8c59a5490c0137184e69d4" }, "downloads": -1, "filename": "cachelock-0.0.2.tar.gz", "has_sig": false, "md5_digest": "3c0eedefd6b77ac4a16eee494356ab97", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4283, "upload_time": "2018-02-04T12:36:56", "url": "https://files.pythonhosted.org/packages/2f/43/34bbe7777e7af6c5574bbdfadc27bd06db281e446203b3109bb06afe0055/cachelock-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "23229f9fd7ba9e7d8a50cd10e724969c", "sha256": "bad57a8e85019787a42d8eda2937d485279de583b6cb279fd5d529bc51ee993b" }, "downloads": -1, "filename": "cachelock-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "23229f9fd7ba9e7d8a50cd10e724969c", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 6256, "upload_time": "2018-02-04T12:41:59", "url": "https://files.pythonhosted.org/packages/7f/6c/0017f287658e4b512badc352fd0509c112e6407f90d8c5333c40d306629d/cachelock-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1044342496f9bd651f7f387444b62f34", "sha256": "b039fd0e434f80de241482652a64cc75e177191636f5c386e71c77cc4bff5d33" }, "downloads": -1, "filename": "cachelock-0.0.3.tar.gz", "has_sig": false, "md5_digest": "1044342496f9bd651f7f387444b62f34", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4284, "upload_time": "2018-02-04T12:41:57", "url": "https://files.pythonhosted.org/packages/c5/aa/b98cf2438195694507cfe279efe760793c1b410dc4111ef163b4ec4a1f6b/cachelock-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "23229f9fd7ba9e7d8a50cd10e724969c", "sha256": "bad57a8e85019787a42d8eda2937d485279de583b6cb279fd5d529bc51ee993b" }, "downloads": -1, "filename": "cachelock-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "23229f9fd7ba9e7d8a50cd10e724969c", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 6256, "upload_time": "2018-02-04T12:41:59", "url": "https://files.pythonhosted.org/packages/7f/6c/0017f287658e4b512badc352fd0509c112e6407f90d8c5333c40d306629d/cachelock-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1044342496f9bd651f7f387444b62f34", "sha256": "b039fd0e434f80de241482652a64cc75e177191636f5c386e71c77cc4bff5d33" }, "downloads": -1, "filename": "cachelock-0.0.3.tar.gz", "has_sig": false, "md5_digest": "1044342496f9bd651f7f387444b62f34", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4284, "upload_time": "2018-02-04T12:41:57", "url": "https://files.pythonhosted.org/packages/c5/aa/b98cf2438195694507cfe279efe760793c1b410dc4111ef163b4ec4a1f6b/cachelock-0.0.3.tar.gz" } ] }