{ "info": { "author": "Roy", "author_email": "cf020031308@163.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Topic :: Database" ], "description": "A tiny redis client for script boys with high performance. Optimized especially for massive insertion.\n\n# Install\n\n`pip install redisio`\n\n# Usage\n\n**TLDR**: The following is the document but don't read it. Instead read [the code](./redisio/redisio.py). It's much shorter.\n\n## Initialize\n\n```python\nimport redisio\nrd = redisio.Redis(host='127.0.0.1', port=6379, db=0, password='')\n```\n\nThe arguments above are set as default so can be omitted.\n\nConnecting via unix sockets is also available.\n\n```python\nimport redisio\nrd = redisio.Redis(socket='/tmp/redis.sock')\n```\n\n## Commands\n\nSee the list of Redis commands at [redis.io](https://redis.io/commands).\n\nSince `redisio` is designed to be implemented strictly in [protocol](https://redis.io/topics/protocol) with little syntax sugar on calling but not any modification on data itself, any future commands of `redis` can be properly supported without update.\n\n### Write I: Commands and Pipelines\n\nInstance `redisio.Redis` is callable.\n\nAny direct calling on it sends the commands (either single command or multiple in list) to the server and then return the client instance itself immediately without reading replies in order to be called in chain conveniently:\n\n```python\nassert rd == rd('SET', 'x', 3)('GET', 'x')(['SET', 'x', 3], ['GET', 'x'])\n```\n\n### Read I: Single Reply\n\nMethod `redisio.Redis.next` returns the first reply in the message queue from the server:\n\n```python\nassert 'OK' == rd('SET', 'x', 3)('GET', 'x').next()\nassert '3' == next(rd)\n```\n\n*Note*: It will be blocked to call `next` when the queue is empty.\n\nReply in the queue can be reached by the index:\n\n```python\nassert '3' == rd('SET', 'x', 3)('GET', 'x')('SET', 'x', 4)[-2]\n```\n\n*Note*: It will first iterate the whole queue and then return the specific reply, with of course a side-effect to empty the queue.\n\nEach redis command is mapped to a method with the same name. \nCalling it in this method-like way will send the command, then read all the replies, and return the last one.\n\n```python\nassert '3' == rd('SET', 'x', 3).get('x')\n```\n\n*Note*: It will be blocked to call `rd.shutdown()` because this command will never be answered (Dead Men Tell No Tales). `rd('SHUTDOWN')` should be used.\n\n### Read II: Multiple Replies\n\nInstance `redisio.Redis` is iterable.\n\nSo iterating it to get all the replies.\n\n```python\nr, = rd(\"HGET\", key, field)\nr1, r2= rd(\"HGET\", key, field)(\"HGET\", key, field2)\nr1, r2= list(rd([\"GET\", key], (\"GET\", key2))([\"SET\", \"X\", \"Y\"]))[:2]\n```\n\n\n### Write II: Massive Insertion\n\nIf you want to insert a large amount of data into redis without the care of the results, you can close the connection after sending it by the use of `del` to avoid parsing the replies.\n\n```python\nrd(*large_scale_of_cmds).__del__()\n```\n\nBenefit from this the massive insertion is blazingly fast: sending a million of HSET cost only 5.355 seconds via `redisio` while it costs 23.918 seconds via `redis-py`.\n\n*Note*: Replies are buffered on the server if the client have not read them while the connection keeps alive. This will eventually make the server crash because of the increasing occupied memory. So be aware.\n\n`redisio` will automatically reset the connection before sending a command in the method-like way while there are more than 1024 replies to read.\n\n```python\nrd(*large_scale_of_cmds).dbsize()\nrd(*large_scale_of_cmds)('DBSIZE')[-1]\n```\n\nThe former is usually faster than the latter because no massive replies need to be read and parsed.\n\n### Pub/Sub/Monitor\n\n```python\nrd.monitor()\n# rd.subscribe('channel')\nwhile 1:\n print next(rd)\n```\n\n# Q&A\n\nQ: Why not using [redis-py](https://github.com/andymccurdy/redis-py) but redisio? \nA: To accomplish the majority of tasks [redis-py](https://github.com/andymccurdy/redis-py) is recommended and mostly used even by myself. Frankly speaking You may never need redisio. redisio is written and optimized especially for massive insertion to be memory-saving and much faster.\n\nQ: How to use redisio in bash? \nA: [redis-cli](https://redis.io/download) is available in bash.\n\nQ: How to use redisio with thread safety? \nA: [redis-py](https://github.com/andymccurdy/redis-py) is thread safe.\n\nQ: Why the result of hgetall is not a dict but a list? \nA: This is the original format of replies from redis-server. Once you get used to this original style, you will be able to process results fluently from redis-cli or [Lua Script](https://redis.io/commands/eval) without the mess of confusing types or structures brought by other brilliant libraries. Anyway let's get down to brass tacks. You can get your dict like this:\n\n```python\nhash_values = rd.hgetall('a_hash_key')\nhash_dict = dict(zip(hash_values[::2], hash_values[1::2]))\n```\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/cf020031308/redisio", "keywords": "Redis,key-value store", "license": "MIT", "maintainer": "Roy", "maintainer_email": "cf020031308@163.com", "name": "redisio", "package_url": "https://pypi.org/project/redisio/", "platform": "", "project_url": "https://pypi.org/project/redisio/", "project_urls": { "Homepage": "https://github.com/cf020031308/redisio" }, "release_url": "https://pypi.org/project/redisio/0.7/", "requires_dist": null, "requires_python": "", "summary": "A tiny redis client for script boys with high performance. Optimized especially for massive insertion.", "version": "0.7" }, "last_serial": 4025559, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "e7f0bb51e75a780d2bd62b8acc3a1f01", "sha256": "dedd036c06363f807d0a64570ebe8caefa4cfa4dc78f9e64054e08991ecca02f" }, "downloads": -1, "filename": "redisio-0.1.tar.gz", "has_sig": false, "md5_digest": "e7f0bb51e75a780d2bd62b8acc3a1f01", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4539, "upload_time": "2017-07-28T16:43:45", "url": "https://files.pythonhosted.org/packages/6b/b7/08aac30d9df33f71deec4c1879c86931ede70378a7ffd6ae9c86da43157d/redisio-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "4315905b5f3e82b2fe45589c9f455903", "sha256": "d863ae3ab028467458c4c2d883e17f5b2e3de09bd3436c80644167bca7848b2e" }, "downloads": -1, "filename": "redisio-0.2.tar.gz", "has_sig": false, "md5_digest": "4315905b5f3e82b2fe45589c9f455903", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4650, "upload_time": "2017-07-28T16:57:26", "url": "https://files.pythonhosted.org/packages/85/1a/1361719354f7059a3078b13cf8304f4ec2b0a34f2d77d795adf990190a88/redisio-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "60b8ab6685c9b739d359a82c613aafb5", "sha256": "84bf31b4f9309218ffe489ce77fec5c9b28b3572b60a11bc50e544c7a3b38683" }, "downloads": -1, "filename": "redisio-0.3.tar.gz", "has_sig": false, "md5_digest": "60b8ab6685c9b739d359a82c613aafb5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5056, "upload_time": "2017-07-29T09:42:25", "url": "https://files.pythonhosted.org/packages/95/87/b066b729bbaf9de165ce866b581ade79dec2a1b59a840968626afd849d72/redisio-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "405f10a58d151cf605bf0c8cc6fbfb28", "sha256": "5324e86772b955ffe22a52d4225d47c93c531a91d8419082fbbdcd64809fbaf9" }, "downloads": -1, "filename": "redisio-0.4.tar.gz", "has_sig": false, "md5_digest": "405f10a58d151cf605bf0c8cc6fbfb28", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5381, "upload_time": "2017-08-01T14:06:18", "url": "https://files.pythonhosted.org/packages/84/57/b03b8b9638cbd93d5d1d261c759b92482b888e24c05a68a9631551e9fa73/redisio-0.4.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "b02eb8d5419ab8e296526b6d5a881d0d", "sha256": "7e6f95ba7d255632926f39163a9ea1197ed52f53ce1c910a9540a047e043e060" }, "downloads": -1, "filename": "redisio-0.5.tar.gz", "has_sig": false, "md5_digest": "b02eb8d5419ab8e296526b6d5a881d0d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5443, "upload_time": "2017-08-25T16:44:29", "url": "https://files.pythonhosted.org/packages/72/47/ebe5ccc2024f67f70f1cd8f0fad571cc8fb546d04d7148bafeb81927c096/redisio-0.5.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "587a443cf3a4c2378f2ce5abacb3fb5d", "sha256": "d2b7e49ccb597c0541772007a583ae12ef5999021cd26b59f2fb0721210fc060" }, "downloads": -1, "filename": "redisio-0.6.tar.gz", "has_sig": false, "md5_digest": "587a443cf3a4c2378f2ce5abacb3fb5d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5510, "upload_time": "2017-11-09T15:15:46", "url": "https://files.pythonhosted.org/packages/b3/4e/6d81071c44a1df48b3dae9eacc885f7956e54d844032bed77e6a6575f35c/redisio-0.6.tar.gz" } ], "0.7": [ { "comment_text": "", "digests": { "md5": "8f6745f9d0e91206ed88b15cf9c1e741", "sha256": "32b36fb0879be05331de4bcd602d0302d8a6fafe3561e3f8d61e48beffe538f2" }, "downloads": -1, "filename": "redisio-0.7-py3-none-any.whl", "has_sig": false, "md5_digest": "8f6745f9d0e91206ed88b15cf9c1e741", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5086, "upload_time": "2018-07-03T09:48:15", "url": "https://files.pythonhosted.org/packages/da/4d/0c90cbdaf26bc8fd59b8639a522db8523e9b9a9676abf0565ec623076cfd/redisio-0.7-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2d7a646bf2daaeefca2bbd840ceb575e", "sha256": "3cdf293d3335970615ed60b88c6b31bb65faebed25dc6f2bb74c060bad50453a" }, "downloads": -1, "filename": "redisio-0.7.tar.gz", "has_sig": false, "md5_digest": "2d7a646bf2daaeefca2bbd840ceb575e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5952, "upload_time": "2018-07-03T09:48:16", "url": "https://files.pythonhosted.org/packages/27/2f/91235b4103addd2c526f56670a9d8ebbc680d49724b4e25f1b714f5208e6/redisio-0.7.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8f6745f9d0e91206ed88b15cf9c1e741", "sha256": "32b36fb0879be05331de4bcd602d0302d8a6fafe3561e3f8d61e48beffe538f2" }, "downloads": -1, "filename": "redisio-0.7-py3-none-any.whl", "has_sig": false, "md5_digest": "8f6745f9d0e91206ed88b15cf9c1e741", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5086, "upload_time": "2018-07-03T09:48:15", "url": "https://files.pythonhosted.org/packages/da/4d/0c90cbdaf26bc8fd59b8639a522db8523e9b9a9676abf0565ec623076cfd/redisio-0.7-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2d7a646bf2daaeefca2bbd840ceb575e", "sha256": "3cdf293d3335970615ed60b88c6b31bb65faebed25dc6f2bb74c060bad50453a" }, "downloads": -1, "filename": "redisio-0.7.tar.gz", "has_sig": false, "md5_digest": "2d7a646bf2daaeefca2bbd840ceb575e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5952, "upload_time": "2018-07-03T09:48:16", "url": "https://files.pythonhosted.org/packages/27/2f/91235b4103addd2c526f56670a9d8ebbc680d49724b4e25f1b714f5208e6/redisio-0.7.tar.gz" } ] }