{ "info": { "author": "Robert Olechowski", "author_email": "RobertOlechowski@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# CallOnce\n\n## What is, the purpose of this project?\nPython decorator that gives ability to to execute given function/method only once and cache results an. The data can be stored not only in memory, but also on disk and remains persistent between application runs. \n\n## How to install:\n```bash\npip install call-once\n```\n\n## How to use:\nLook to test directory to get idea. Code is compatible with python >= 3.4\n\n### Simple example\n```python\nimport CallOnce\nfrom CallOnce.Enums import ArgumentsMode\n\n\n@CallOnce.CallOnce(args_mode=ArgumentsMode.SERIALIZE_AND_HASH)\ndef plus_one(value):\n print (\"Function invoked for {}\".format(value))\n return value + 1\n\nprint(plus_one(5))\nprint(plus_one(5))\nprint(plus_one(10))\n\n# Function invoked for 5\n# 6\n# 6\n# Function invoked for 10\n# 11\n```\n\n### Example with TTL\n```python\nfrom datetime import timedelta\nimport CallOnce\n\n@CallOnce.CallOnce(ttl=timedelta(milliseconds=100))\ndef plus_one(value):\n print (\"Function invoked for {}\".format(value))\n return value + 1\n\nprint(plus_one(5))\nprint(plus_one(5))\nfrom time import sleep\nsleep(0.5)\nprint(plus_one(5))\nprint(plus_one(5))\n\n# Function invoked for 5\n# 6\n# Function invoked for 5\n# 6\n```\n\n\n## What are arguments of decorator?\n##### args_mode\n* ArgumentsMode.SERIALIZE_AND_HASH - Arguments of invocation are hashed \n* ArgumentsMode.IGNORE - Arguments are ignored and result of first invocation is cashed (Default)\n\n##### hash_mode\n* HashFunction.PYTHON - Standard Python Hash function is in use (Default)\n* HashFunction.MD5 - MD5\n\n##### ttl\nObject of type datetime.timedelta that defines for how long given result should be cache. If None than we will remember it forever. \nDefault is None\n\n\n## ToDo:\n* Improve tests for dictionary mode\n* Add Serialisation and persistent storage on hard drive\n\n\n\n\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/RobertOlechowski/CallOnce", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "call-once", "package_url": "https://pypi.org/project/call-once/", "platform": "", "project_url": "https://pypi.org/project/call-once/", "project_urls": { "Homepage": "https://github.com/RobertOlechowski/CallOnce" }, "release_url": "https://pypi.org/project/call-once/1.1.1/", "requires_dist": null, "requires_python": "", "summary": "Python decorator that gives ability to execute given function/method only once and cache results. The data can be stored not only in memory, but also on disk and remains persistent between application runs.", "version": "1.1.1" }, "last_serial": 4851514, "releases": { "1.1": [ { "comment_text": "", "digests": { "md5": "5578058d2dd24b972280e27d02f74dba", "sha256": "202de68c4c91b244725df339b57d4c468c89e6a9440e5e4b47286cf57a2f265d" }, "downloads": -1, "filename": "call_once-1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "5578058d2dd24b972280e27d02f74dba", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4574, "upload_time": "2019-02-21T19:13:52", "url": "https://files.pythonhosted.org/packages/f4/b2/394ec9dfe1542ca6b6c66661cbf110d2b940e7a1ca6268c3094b24109348/call_once-1.1-py3-none-any.whl" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "7a59ae3e671a75a1d6b53b0be62f7627", "sha256": "bea14903ddf8860c36d8e9a6e4c9b1250177f95b9a0ee3391995a9bac445ec3b" }, "downloads": -1, "filename": "call_once-1.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "7a59ae3e671a75a1d6b53b0be62f7627", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4552, "upload_time": "2019-02-21T19:36:27", "url": "https://files.pythonhosted.org/packages/04/69/7eca947be14a52e219aa2dd907f3b75a3056a2c2b9cb3d3456123f868e5e/call_once-1.1.1-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7a59ae3e671a75a1d6b53b0be62f7627", "sha256": "bea14903ddf8860c36d8e9a6e4c9b1250177f95b9a0ee3391995a9bac445ec3b" }, "downloads": -1, "filename": "call_once-1.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "7a59ae3e671a75a1d6b53b0be62f7627", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4552, "upload_time": "2019-02-21T19:36:27", "url": "https://files.pythonhosted.org/packages/04/69/7eca947be14a52e219aa2dd907f3b75a3056a2c2b9cb3d3456123f868e5e/call_once-1.1.1-py3-none-any.whl" } ] }