{ "info": { "author": "Taylor Hakes", "author_email": "", "bugtrack_url": null, "classifiers": [], "description": "# python-redis-cache\nSimple redis cache for Python functions\n\n### Requirements\n- Redis 5+\n- Python 3.6+\n\n## How to install\n```\npip install python-redis-cache\n```\n\n## How to use\n```python\nfrom redis import StrictRedis\nfrom redis_cache import RedisCache\n\nclient = StrictRedis(host=\"redis\", decode_responses=True)\ncache = RedisCache(redis_client=client)\n\n\n@cache.cache()\ndef my_func(arg1, arg2):\n result = some_expensive_operation()\n return result\n\n# Use the function\nmy_func(1, 2)\n\n# Call it again with the same arguments and it will use cache\nmy_func(1, 2)\n\n# Invalidate a single value\nmy_func.invalidate(1, 2)\n\n# Invalidate all values for function\nmy_func.invalidate_all()\n```\n\n## Limitations and things to know\nArguments and return types must be JSON serializable by default. You can override the serializer, but be careful with using Pickle. Make sure you understand the security risks. Pickle should not be used with untrusted values.\nhttps://security.stackexchange.com/questions/183966/safely-load-a-pickle-file\n\n- **ttl** - is based on the time from when it's first inserted in the cache, not based on the last access\n- **limit** - The limit will revoke keys (once it hits the limit) based on FIFO, not based on LRU\n\n## API\n```python\nRedisCache(redis_client, prefix=\"rc\", serializer=dumps, deserializer=loads)\n\nRedisCache.cache(ttl=None, limit=None, namespace=None)\n\n# Cached function API\n\n# Returns a cached value, if it exists in cache. Saves value in cache if it doesn't exist\ncached_func(*args, *kwargs)\n\n# Invalidates a single value\ncached_func.invalidate(*args, **kwargs)\n\n# Invalidates all values for cached function\ncached_func.invalidate_all()\n```\n\n- prefix - The string to prefix the redis keys with\n- serializer/deserializer - functions to convert arguments and return value to a string (user JSON by default)\n- ttl - The time in seconds to cache the return value\n- namespace - The string namespace of the cache. This is useful for allowing multiple functions to use the same cache. By default its `f'{function.__module__}.{function.__file__}'`", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/taylorhakes/python-redis-cache", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "python-redis-cache", "package_url": "https://pypi.org/project/python-redis-cache/", "platform": "", "project_url": "https://pypi.org/project/python-redis-cache/", "project_urls": { "Homepage": "http://github.com/taylorhakes/python-redis-cache" }, "release_url": "https://pypi.org/project/python-redis-cache/1.1.0/", "requires_dist": null, "requires_python": "", "summary": "Basic Redis caching for functions", "version": "1.1.0" }, "last_serial": 5554640, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "40eb46144846188acb9224cdd64686ca", "sha256": "c695ac67855ec9ea6a326022d15594f6cf6ee592a09e7cdcc1340cbbecf90d4c" }, "downloads": -1, "filename": "python-redis-cache-0.1.tar.gz", "has_sig": false, "md5_digest": "40eb46144846188acb9224cdd64686ca", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1946, "upload_time": "2019-05-08T06:05:58", "url": "https://files.pythonhosted.org/packages/cb/40/1445a3d44a02a2d103c8ab5a88b4f60e06b783497c579c3b90f2f546ab09/python-redis-cache-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "7cda4b34e2ab9ca68d238e3b80a06792", "sha256": "1cf309c36a26ee48889507e130ceeeb5d58e33f4b085ef0c2a6ba009f277fd21" }, "downloads": -1, "filename": "python-redis-cache-0.2.tar.gz", "has_sig": false, "md5_digest": "7cda4b34e2ab9ca68d238e3b80a06792", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1936, "upload_time": "2019-05-08T06:07:13", "url": "https://files.pythonhosted.org/packages/ca/ff/50de719e6512d545296391270b53f18b9d29b471b9aadd048b6766144637/python-redis-cache-0.2.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "06154331269b83e9a647c0fb4473cc88", "sha256": "1b3b7787e7cb74a639b5f6ea4e47d10a036dacdbbd5f13c1523d712e0f4b279f" }, "downloads": -1, "filename": "python-redis-cache-0.3.0.tar.gz", "has_sig": false, "md5_digest": "06154331269b83e9a647c0fb4473cc88", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2690, "upload_time": "2019-05-08T06:23:47", "url": "https://files.pythonhosted.org/packages/c5/0f/1b1eec28dc5d6faeb278bb6c267128fbe4529999477d4440e0c9f4abe64e/python-redis-cache-0.3.0.tar.gz" } ], "0.5.0": [ { "comment_text": "", "digests": { "md5": "3118ce148fbd94fb831a423ea2d2a1b4", "sha256": "addb5c2093b67e486544bf565601e4867f5eecf1e3c1c0e819687099c3cabe0e" }, "downloads": -1, "filename": "python-redis-cache-0.5.0.tar.gz", "has_sig": false, "md5_digest": "3118ce148fbd94fb831a423ea2d2a1b4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2971, "upload_time": "2019-05-10T13:25:42", "url": "https://files.pythonhosted.org/packages/1c/33/5d8761a4875e6dbb634ce6f06e77ec0cd445ed3b1fa1effad3ac4b3efaed/python-redis-cache-0.5.0.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "bf61be98d1c608736fbfd965b4b59cff", "sha256": "4d38a39a10a3f9703f501502ea01565e7af438d9a2a0e3165e6546aea58fda02" }, "downloads": -1, "filename": "python-redis-cache-1.0.0.tar.gz", "has_sig": false, "md5_digest": "bf61be98d1c608736fbfd965b4b59cff", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3520, "upload_time": "2019-05-11T18:32:36", "url": "https://files.pythonhosted.org/packages/86/08/919badfb2904d52aebacc3257524687b434067df66da3df2524c2ebfdbe0/python-redis-cache-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "ae6e186ae22b57fe7d278803f1be5279", "sha256": "9694bd767c788d50de412628db86358d9f100ac7f5bf20e6b96aedbf03b54675" }, "downloads": -1, "filename": "python-redis-cache-1.0.1.tar.gz", "has_sig": false, "md5_digest": "ae6e186ae22b57fe7d278803f1be5279", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4130, "upload_time": "2019-05-15T12:47:03", "url": "https://files.pythonhosted.org/packages/bd/ef/16f5e7789a06c6c1e7ceb1660c08b12bb740acd682f0c50bc1771c5a7a64/python-redis-cache-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "ada7a545952677def3299a2cc225c7b9", "sha256": "46bc2073921768d9753dbd9535e3e36781e27224d83a350c39474d9eb1be78f1" }, "downloads": -1, "filename": "python-redis-cache-1.0.2.tar.gz", "has_sig": false, "md5_digest": "ada7a545952677def3299a2cc225c7b9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4247, "upload_time": "2019-05-23T05:09:11", "url": "https://files.pythonhosted.org/packages/e0/fe/b8131eedb937a32df04b3bc02fe74fa2cbc29102330ed222d52ae1435e98/python-redis-cache-1.0.2.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "f4d5fa0b8c236d632cd16ef40fb04a33", "sha256": "09f686b9f2cde9414809ae987e14321e808e553fbbf297421de90c1253af7388" }, "downloads": -1, "filename": "python-redis-cache-1.1.0.tar.gz", "has_sig": false, "md5_digest": "f4d5fa0b8c236d632cd16ef40fb04a33", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4687, "upload_time": "2019-07-19T05:18:30", "url": "https://files.pythonhosted.org/packages/76/31/d399d882cd31e71665b7b6b480a7c22b2999532d0ec75a77d1b72f5dba51/python-redis-cache-1.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f4d5fa0b8c236d632cd16ef40fb04a33", "sha256": "09f686b9f2cde9414809ae987e14321e808e553fbbf297421de90c1253af7388" }, "downloads": -1, "filename": "python-redis-cache-1.1.0.tar.gz", "has_sig": false, "md5_digest": "f4d5fa0b8c236d632cd16ef40fb04a33", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4687, "upload_time": "2019-07-19T05:18:30", "url": "https://files.pythonhosted.org/packages/76/31/d399d882cd31e71665b7b6b480a7c22b2999532d0ec75a77d1b72f5dba51/python-redis-cache-1.1.0.tar.gz" } ] }