{ "info": { "author": "Tom Tang", "author_email": "tly1980@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Plugins", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": "|PyPI version| |Build Status| |Supported Python Versions|\n\nTTL Memoized - A memoized decorator with TTL (time-to-live) support.\n====================================================================\n\nThe idea of ``memoized`` is great, as some resources are expensive, so\nyou want to cache them.\n\nHowever, there isn't a memoized lib support TTL (time-to-live) at the\nmoment, or I haven't find any thing yet.\n\nSo I implement this\n`ttl\\_memoized `__ to fill in\nthe gap here.\n\nAlso, this lib is meant to be thread-safe, using\n`threading.local `__\nobject to store the variables.\n\nInstallation:\n-------------\n\nShould be faily simple using pip:\n\n::\n\n pip install ttl_memoized\n\nUsage\n-----\n\nThe usage is simple, and the best way to explain it, is with my test\ncases:\n\n::\n\n def test_basic():\n\n @memoized(ttl=0.5)\n def a(name):\n return datetime.datetime.now()\n\n @memoized(ttl=0.5)\n def b(name, *args, **kwargs):\n return datetime.datetime.now()\n\n a1 = a(1)\n b1 = b(1, 2, 3, what='ever', you='want', to='be')\n\n for i in range(100):\n assert a1 == a(1)\n\n for i in range(100):\n assert b1 is b(1, 2, 3, what='ever', you='want', to='be')\n\n a2 = a(2)\n assert a2 != a1\n\n # let the cache expired...\n time.sleep(0.51)\n\n assert a(1) != a1\n assert b1 != b(1, 2, 3, what='ever', you='want', to='be')\n\nCeveat\n------\n\nThe parameter for the functions is required to be serializable with\n`json `__ libs, as the lib\nis using json to build the keys from parameters.\n\n.. |PyPI version| image:: https://badge.fury.io/py/ttl_memoized.svg\n :target: https://badge.fury.io/py/ttl_memoized\n.. |Build Status| image:: https://travis-ci.org/tly1980/ttl_memoized.svg?branch=master\n :target: https://travis-ci.org/tly1980/ttl_memoized\n.. |Supported Python Versions| image:: https://img.shields.io/badge/python-2.6%2C%202.7%2C%203.3%2C%203.4%2C%203.5%2C%203.6-blue.svg\n :target: https://travis-ci.org/tly1980/ttl_memoized\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/tly1980/ttl_memoized", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "ttl_memoized", "package_url": "https://pypi.org/project/ttl_memoized/", "platform": "", "project_url": "https://pypi.org/project/ttl_memoized/", "project_urls": { "Homepage": "http://github.com/tly1980/ttl_memoized" }, "release_url": "https://pypi.org/project/ttl_memoized/0.2.1/", "requires_dist": null, "requires_python": "", "summary": "TTLMemoized - a memoized decorator with TTL (time-to-live) support", "version": "0.2.1" }, "last_serial": 3255647, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "edfe5dbbabde9208a4eeb1ac112483a5", "sha256": "c47339222f3926e8892b0edfe06d168168d738574c2a4477da1ab8c4a354dfde" }, "downloads": -1, "filename": "ttl_memoized-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "edfe5dbbabde9208a4eeb1ac112483a5", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 3766, "upload_time": "2017-10-17T05:53:12", "url": "https://files.pythonhosted.org/packages/25/b6/a8e6363de0ef770bfeff01c1b3d4a45ab50b6f364baec901ce5b81a3386b/ttl_memoized-0.1.0-py2.py3-none-any.whl" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "799153b29fa3ffa96f1a74cd695a5fa0", "sha256": "da1de372fc4659481485772caf127ee0b82ad3ee4691e894d441e7a5421bc475" }, "downloads": -1, "filename": "ttl_memoized-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "799153b29fa3ffa96f1a74cd695a5fa0", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 4047, "upload_time": "2017-10-17T06:22:12", "url": "https://files.pythonhosted.org/packages/09/9d/30909174c1ca1a20c49c7fdb16b8309a4a29cb47666b1d41267830f54337/ttl_memoized-0.2.0-py2.py3-none-any.whl" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "7cb3a1d7f3b776d78fab704a0c16bc46", "sha256": "0ad0f1efbac5d2dc0295054b58a93651ffb55c2e67aa31def4bfdd28e23b52b4" }, "downloads": -1, "filename": "ttl_memoized-0.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "7cb3a1d7f3b776d78fab704a0c16bc46", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 4429, "upload_time": "2017-10-17T06:39:21", "url": "https://files.pythonhosted.org/packages/6d/c7/1b0547aa87a97f2e464e569df190b5604dea2b5ad3f449a7eccbe8bbe54b/ttl_memoized-0.2.1-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7cb3a1d7f3b776d78fab704a0c16bc46", "sha256": "0ad0f1efbac5d2dc0295054b58a93651ffb55c2e67aa31def4bfdd28e23b52b4" }, "downloads": -1, "filename": "ttl_memoized-0.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "7cb3a1d7f3b776d78fab704a0c16bc46", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 4429, "upload_time": "2017-10-17T06:39:21", "url": "https://files.pythonhosted.org/packages/6d/c7/1b0547aa87a97f2e464e569df190b5604dea2b5ad3f449a7eccbe8bbe54b/ttl_memoized-0.2.1-py2.py3-none-any.whl" } ] }