{ "info": { "author": "Gianni Saporiti", "author_email": "saporitigianni@outlook.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Topic :: Internet", "Topic :: Internet :: WWW/HTTP", "Topic :: Software Development :: Build Tools", "Topic :: System :: Networking" ], "description": ".. -*-restructuredtext-*-\n\nmemorize: A caching package with options for timed caching and caching aware rate limiting\n==========================================================================================\n\n.. image:: https://img.shields.io/badge/Made%20with-Python-1f425f.svg\n :target: https://www.python.org/\n\n.. image:: https://img.shields.io/pypi/v/memorize.svg\n :target: https://pypi.org/project/memorize/\n\n.. image:: https://img.shields.io/pypi/l/memorize.svg\n :target: https://pypi.org/project/memorize/\n\n.. image:: https://img.shields.io/pypi/pyversions/memorize.svg\n :target: https://pypi.org/project/memorize/\n\nInstallation\n------------\n\nTo install memorize, simply use pip:\n\n.. code:: bash\n\n $ pip install memorize\n\nor install directly from source to include latest changes:\n\n.. code:: bash\n\n $ pip install git+https://github.com/saporitigianni/memorize.git\n\nor clone and then install:\n\n.. code:: bash\n\n $ git clone https://github.com/saporitigianni/memorize.git\n $ cd memorize\n $ python3 setup.py install\n\nUsage\n-----\n\nThis class extends the functools.lru_cache functionality to add timed caching and caching aware rate limiting\n(e.g. if call results are returned from the cache then that particular call does not affect the rate limit)\n\n**Constraints:**\n - Since a dictionary is used to cache results, the positional and keyword arguments to the function must be hashable (NOT lists, dicts, sets, or any other object that does not define hash())\n - It is very important to use the parenthesis even if empty: **@memorize()** NOT **@memorize**\n - When rate limiting, both the **calls** and **period** arguments must be provided otherwise an error is raised\n\n**Default Settings:**\n - timeout = None (can be int or float)\n - maxsize = None (can be int)\n - typed = False (can be True)\n - calls = None (can be int)\n - period = None (can be int or float)\n - aware = False (can be True)\n\n.. code:: python\n\n from memorize import memorize\n\n # If you want to use all default settings\n @memorize()\n def fib(n):\n if n < 2:\n return n\n else:\n return fib(n-2) + fib(n-1)\n\n # With memorization fib(20) will be run 21 times instead of 21891 times\n # without memorization\n fib(20)\n\n # If you want to cache a maximum of 128 calls, cached by different types,\n # each for 10 seconds use:\n @memorize(timeout=10, maxsize=128, typed=True)\n\n # If you want to implement caching aware rate limiting then use the following:\n # This will limit to no more than 10 calls for every 5 second period and if a\n # result is returned from the cache it does not count towards the 10 calls.\n @memorize(calls=10, period=5, aware=True)\n\n\nContributing\n------------\n\nPlease read the `CONTRIBUTING `_ document before making changes that you would like adopted in the code.\n\nCode of Conduct\n---------------\n\nEveryone interacting in the ``memorize`` project's codebase, issue\ntrackers, chat rooms, and mailing lists is expected to follow the\n`PyPA Code of Conduct `_.:octocat:\n\n|\n|\n| ETH 0xaD1F09626b9B8e701D5f0F4a237193Df73d3C445\n| BTC 199zsVqCusefv8yjdYQhUQZmLCyh75dqNV\n| LTC LUBqs7VxC43ttPsQuM1jaZFmshKTAU1Rs9", "description_content_type": "", "docs_url": null, "download_url": "https://pypi.python.org/pypi/memorize", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/saporitigianni/memorize", "keywords": "cache,caching,decorator,rate-limit,timeout,timer", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "memorize", "package_url": "https://pypi.org/project/memorize/", "platform": "", "project_url": "https://pypi.org/project/memorize/", "project_urls": { "Download": "https://pypi.python.org/pypi/memorize", "Homepage": "https://github.com/saporitigianni/memorize" }, "release_url": "https://pypi.org/project/memorize/0.1.1/", "requires_dist": null, "requires_python": ">=3", "summary": "A caching package with options for timed caching and caching aware rate limiting", "version": "0.1.1" }, "last_serial": 3907618, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "6301ea139f2c0b9f89071703991b2f38", "sha256": "89f64cac7790d4c979b67efe0a189b294439422c213109918e0a3b8ad9dcd6cd" }, "downloads": -1, "filename": "memorize-0.1.1.tar.gz", "has_sig": false, "md5_digest": "6301ea139f2c0b9f89071703991b2f38", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 7202, "upload_time": "2018-05-29T04:58:22", "url": "https://files.pythonhosted.org/packages/f4/74/13c9396b079b4992755e04900c906e8fc9f6d27f0fda55db02aaf9365518/memorize-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6301ea139f2c0b9f89071703991b2f38", "sha256": "89f64cac7790d4c979b67efe0a189b294439422c213109918e0a3b8ad9dcd6cd" }, "downloads": -1, "filename": "memorize-0.1.1.tar.gz", "has_sig": false, "md5_digest": "6301ea139f2c0b9f89071703991b2f38", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3", "size": 7202, "upload_time": "2018-05-29T04:58:22", "url": "https://files.pythonhosted.org/packages/f4/74/13c9396b079b4992755e04900c906e8fc9f6d27f0fda55db02aaf9365518/memorize-0.1.1.tar.gz" } ] }