{ "info": { "author": "barisumog", "author_email": "barisumog@gmail.com", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python :: 3.3" ], "description": "simple_cache\r\n============\r\n\r\nA simple caching utility in Python 3.\r\n\r\n**simple_cache** uses the ``pickle`` module to write any\r\n``key : value`` pairs to a file on disk.\r\n\r\nIt was written as an easy way to cache http requests for\r\nlocal use. It can possibly be used for caching any data,\r\nas long as the ``key`` s are hashable and the ``value`` s are\r\npickleable.\r\n\r\nIt also provides a decorator to cache function calls directly.\r\n\r\n\r\nRequirements\r\n------------\r\n\r\nOnly standard libraries are used, so there are no dependencies.\r\n\r\n\r\nInstalling\r\n----------\r\n\r\n::\r\n\r\n pip install simple_cache\r\n\r\n\r\nOr if you like, you can just download the ``simple_cache.py`` file and\r\nimport it locally.\r\n\r\n\r\nUsage\r\n-----\r\n\r\nEach cache file contains a single dictionary, acting as the namespace\r\nfor that cache. Within the file, you can set and retrieve any ``key : value``\r\npairs as needed.\r\n\r\nWhen setting a key, you must give a ``ttl`` value, or time to live, in seconds.\r\nThis value determines the amount of time that value will be considered valid.\r\nAfter that, the value is considered expired, and will not be returned.\r\n\r\nCalls to a non-existent cache file, a non-existent key, or an expired key\r\nall return ``None``.\r\n\r\nYou can set a key with a new value before or after it expires.\r\n\r\nWhenever you ask the cache for a value, and it happens to be expired, the item\r\nis deleted from the file. You can also manually ask the cache file at any time,\r\nto prune all currently expired items.\r\n\r\n\r\nAPI\r\n---\r\n\r\n::\r\n\r\n import simple_cache\r\n\r\n**Using the decorator format:**\r\n\r\nUsing the same cache file for multiple functions with a decorator might\r\ncause problems. The decorator uses the ``*args, **kwargs`` of the function as a key,\r\nso calling to different functions with the same arguments will cause a clash.\r\n\r\nYou can specify a custom filename (and ttl) with the decorator format, overriding\r\nthe default values.\r\n\r\n*Please note that the decorator format only supports args and kwargs with* **immutable** *types.\r\nIf one of your arguments is mutable (e.g. a list, or a dictionary), the decorator won't work.*\r\n\r\n::\r\n\r\n @simple_cache.cache_it() # uses defaults: filename = \"simple.cache\", ttl = 3600\r\n def some_function(*args, **kwargs):\r\n # body\r\n return value\r\n\r\n::\r\n\r\n @simple_cache.cache_it(filename=\"some_function.cache\", ttl=120)\r\n def some_function(*args, **kwargs):\r\n # body\r\n return value\r\n\r\n\r\n**Using the module functions:**\r\n\r\nSetting a key and value:\r\n\r\n::\r\n\r\n simple_cache.save_key(filename, key, value, ttl)\r\n\r\nRetrieving a value:\r\n\r\n::\r\n\r\n simple_cache.load_key(filename, key)\r\n\r\nPruning all expired items in a file:\r\n\r\n::\r\n\r\n simple_cache.prune_cache(filename)\r\n\r\nLoading the whole cache dictionary from a file (possibly\r\nfor debugging or introspection):\r\n\r\n::\r\n\r\n simple_cache.read_cache(filename)\r\n\r\nWriting a whole dictionary to a file, **overwriting any\r\nprevious data in the file** (possibly for initalizing a \r\ncache by batch writing multiple items):\r\n\r\n::\r\n\r\n simple_cache.write_cache(filename, cache)\r\n\r\n\r\n``filename`` is a string containing a valid filename\r\n\r\n``key`` is any hashable type, and must be unique within\r\neach cache file (otherwise will overwrite)\r\n\r\n``value`` is any Python type supported by the ``pickle`` module\r\n\r\n``ttl`` is an integer or float, denoting the number of seconds\r\nthat the item will remain valid before it expires\r\n\r\n``cache`` is a dictionary containing the key:value pairs\r\n\r\n\r\nLicense\r\n-------\r\n\r\n**simple_cache** is open sourced under GPLv3.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/barisumog/simple_cache", "keywords": "", "license": "GPLv3", "maintainer": "", "maintainer_email": "", "name": "simple_cache", "package_url": "https://pypi.org/project/simple_cache/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/simple_cache/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/barisumog/simple_cache" }, "release_url": "https://pypi.org/project/simple_cache/0.35/", "requires_dist": null, "requires_python": null, "summary": "A simple caching utility in Python 3", "version": "0.35" }, "last_serial": 799558, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "c8a757946d1ba90904bab00fb59f7738", "sha256": "11a5464d12aba12b0b97e3d1fd83fc3559276f92f31ea2e06437a053739cdbaf" }, "downloads": -1, "filename": "simple_cache-0.1.zip", "has_sig": false, "md5_digest": "c8a757946d1ba90904bab00fb59f7738", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3432, "upload_time": "2013-03-26T13:10:06", "url": "https://files.pythonhosted.org/packages/15/f3/90d528d3ad3a882d889ecee8cf68c0c8dff03391dec10572762a09851ea5/simple_cache-0.1.zip" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "72e5c9e58d1600c10f1df4fa6778c48f", "sha256": "b5b3ebc272cb9fdb16929a3eabab4db13e4f1b2ee38043f0d1efb17e2865b16b" }, "downloads": -1, "filename": "simple_cache-0.2.zip", "has_sig": false, "md5_digest": "72e5c9e58d1600c10f1df4fa6778c48f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4603, "upload_time": "2013-03-26T13:14:57", "url": "https://files.pythonhosted.org/packages/6e/48/e09ed1ce462a4f1667ba9952207b35112952a3c8d164b5f0ec7326d9094b/simple_cache-0.2.zip" } ], "0.21": [ { "comment_text": "", "digests": { "md5": "6d17025aba7ae8682b3d139a1ed013c3", "sha256": "438cb5fa5188b22d0881af938dfcd4ba07bd23753116c54a8f7524334c886d62" }, "downloads": -1, "filename": "simple_cache-0.21.zip", "has_sig": false, "md5_digest": "6d17025aba7ae8682b3d139a1ed013c3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3497, "upload_time": "2013-03-26T13:53:14", "url": "https://files.pythonhosted.org/packages/ae/88/251e2ad62ac216593e47a1cb19dc01303c64e5fd7471c7bac64cb6dc1ede/simple_cache-0.21.zip" } ], "0.30": [ { "comment_text": "", "digests": { "md5": "e488cc31f5684db86a84b808f4d25561", "sha256": "ae93409b2bda4dfb1cc67b9a83d7049c5d20d305b6ee8615ec01d220b8a27332" }, "downloads": -1, "filename": "simple_cache-0.30.zip", "has_sig": false, "md5_digest": "e488cc31f5684db86a84b808f4d25561", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4220, "upload_time": "2013-03-28T10:14:41", "url": "https://files.pythonhosted.org/packages/8f/a9/f862bc702c0911e72b3e0c25490d40da1e052b6f0a5b4910f310967d7ebd/simple_cache-0.30.zip" } ], "0.31": [ { "comment_text": "", "digests": { "md5": "c47de74836dc19b8816a7a73fe372454", "sha256": "a3f848876be95d226fa703d232def6c2cb9c103bf3a207363de9b4fa82fa2f9d" }, "downloads": -1, "filename": "simple_cache-0.31.zip", "has_sig": false, "md5_digest": "c47de74836dc19b8816a7a73fe372454", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4223, "upload_time": "2013-03-28T10:23:01", "url": "https://files.pythonhosted.org/packages/80/61/19d13f9a94468b761e9593afca40113503d504c1568da050e0ea124051ea/simple_cache-0.31.zip" } ], "0.32": [ { "comment_text": "", "digests": { "md5": "cb4637fac5ba33f1d46d57630efe5a04", "sha256": "649e6bb545ef97ee562dc328068ec9f16c52beb8f0c8dcfd2652707e303de244" }, "downloads": -1, "filename": "simple_cache-0.32.zip", "has_sig": false, "md5_digest": "cb4637fac5ba33f1d46d57630efe5a04", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4223, "upload_time": "2013-03-28T10:30:29", "url": "https://files.pythonhosted.org/packages/b4/73/6bb6c30d95536994b13b46143d1b1a2553e840a6d7d04d6dcff5a8ee196d/simple_cache-0.32.zip" } ], "0.33": [ { "comment_text": "", "digests": { "md5": "50a668a7a14dbb6ddd23f927491a44c5", "sha256": "aaae57f9bc5ae52061e265a73c9e850aec5a157365c2771b1e30a8eccdeea316" }, "downloads": -1, "filename": "simple_cache-0.33.zip", "has_sig": false, "md5_digest": "50a668a7a14dbb6ddd23f927491a44c5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4220, "upload_time": "2013-03-28T10:31:40", "url": "https://files.pythonhosted.org/packages/c0/9d/d768d15eefcbbfcd29437679060e2f78b89367f2845281f5346a3fe26a76/simple_cache-0.33.zip" } ], "0.34": [ { "comment_text": "", "digests": { "md5": "94b5462edda8468fd27079074b2efe56", "sha256": "d9b232544545adb19a39c89ce9087414f12ef0aec5a3ff65d11eba12c8423f3b" }, "downloads": -1, "filename": "simple_cache-0.34.zip", "has_sig": false, "md5_digest": "94b5462edda8468fd27079074b2efe56", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5844, "upload_time": "2013-03-28T13:43:17", "url": "https://files.pythonhosted.org/packages/ca/5b/1e2969a08a860e55515e19cd4ddc87804990f54486f506bb7906ec634ff0/simple_cache-0.34.zip" } ], "0.35": [ { "comment_text": "", "digests": { "md5": "867101083449a441c76ce4426eab6d79", "sha256": "070809009eb3abe55b8d55bec5c009a642291b53313e40dd1e15e1389038ee25" }, "downloads": -1, "filename": "simple_cache-0.35.zip", "has_sig": false, "md5_digest": "867101083449a441c76ce4426eab6d79", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5870, "upload_time": "2013-03-28T13:46:14", "url": "https://files.pythonhosted.org/packages/0a/f6/37e0b6dece682407b841bbab68dbe57e079de4811bb372c191a865bf6118/simple_cache-0.35.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "867101083449a441c76ce4426eab6d79", "sha256": "070809009eb3abe55b8d55bec5c009a642291b53313e40dd1e15e1389038ee25" }, "downloads": -1, "filename": "simple_cache-0.35.zip", "has_sig": false, "md5_digest": "867101083449a441c76ce4426eab6d79", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5870, "upload_time": "2013-03-28T13:46:14", "url": "https://files.pythonhosted.org/packages/0a/f6/37e0b6dece682407b841bbab68dbe57e079de4811bb372c191a865bf6118/simple_cache-0.35.zip" } ] }