{"id":13500968,"url":"https://github.com/nrk/redis-lua","last_synced_at":"2025-10-21T03:55:59.218Z","repository":{"id":529497,"uuid":"158382","full_name":"nrk/redis-lua","owner":"nrk","description":"A Lua client library for the redis key value storage system.","archived":false,"fork":false,"pushed_at":"2023-11-06T14:23:02.000Z","size":638,"stargazers_count":748,"open_issues_count":38,"forks_count":238,"subscribers_count":53,"default_branch":"version-2.0","last_synced_at":"2025-10-21T03:55:40.781Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nrk.png","metadata":{"files":{"readme":"README.markdown","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2009-03-24T18:58:15.000Z","updated_at":"2025-09-26T06:32:33.000Z","dependencies_parsed_at":"2024-01-08T20:19:18.318Z","dependency_job_id":null,"html_url":"https://github.com/nrk/redis-lua","commit_stats":{"total_commits":318,"total_committers":12,"mean_commits":26.5,"dds":0.0691823899371069,"last_synced_commit":"880dda904909adfed0ad79cdd80317c6dd1a005a"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/nrk/redis-lua","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nrk%2Fredis-lua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nrk%2Fredis-lua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nrk%2Fredis-lua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nrk%2Fredis-lua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nrk","download_url":"https://codeload.github.com/nrk/redis-lua/tar.gz/refs/heads/version-2.0","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nrk%2Fredis-lua/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280200865,"owners_count":26289477,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T22:01:20.931Z","updated_at":"2025-10-21T03:55:59.200Z","avatar_url":"https://github.com/nrk.png","language":"Lua","funding_links":[],"categories":["Lua","资源","Resources","Haskell"],"sub_categories":["Data Stores","Database drivers","Lua"],"readme":"# redis-lua #\n\n## About ##\n\nredis-lua is a pure Lua client library for the Redis advanced key-value database.\n\n## Main features ##\n\n- Support for Redis \u003e= 1.2\n- Command pipelining\n- Redis transactions (MULTI/EXEC) with CAS\n- User-definable commands\n- UNIX domain sockets (when available in LuaSocket)\n\n## Compatibility ##\n\nThis library is tested and works with __Lua 5.1__, __Lua 5.2__ (using a compatible\nversion of LuaSocket) and __LuaJit 2.0__.\n\n## Examples of usage ##\n\n### Include redis-lua in your script ###\n\nJust require the `redis` module assigning it to a variable:\n\n``` lua\nlocal redis = require 'redis'\n```\n\nPrevious versions of the library defined a global `Redis` alias as soon as the module was\nimported by the user. This global alias is still defined but it is considered deprecated\nand it will be removed in the next major version.\n\n### Connect to a redis-server instance and send a PING command ###\n\n``` lua\nlocal redis = require 'redis'\nlocal client = redis.connect('127.0.0.1', 6379)\nlocal response = client:ping()           -- true\n```\n\nIt is also possible to connect to a local redis instance using __UNIX domain sockets__\nif LuaSocket has been compiled with them enabled (unfortunately it is not the default):\n\n``` lua\nlocal redis = require 'redis'\nlocal client = redis.connect('unix:///tmp/redis.sock')\n```\n\n### Set keys and get their values ###\n\n``` lua\nclient:set('usr:nrk', 10)\nclient:set('usr:nobody', 5)\nlocal value = client:get('usr:nrk')      -- 10\n```\n\n### Sort list values by using various parameters supported by the server ###\n\n``` lua\nfor _,v in ipairs({ 10,3,2,6,1,4,23 }) do\n    client:rpush('usr:nrk:ids',v)\nend\n\nlocal sorted = client:sort('usr:nrk:ids', {\n     sort = 'asc', alpha = true, limit = { 1, 5 }\n})      -- {1=10,2=2,3=23,4=3,5=4}\n```\n\n### Pipeline commands\n\n``` lua\nlocal replies = client:pipeline(function(p)\n    p:incrby('counter', 10)\n    p:incrby('counter', 30)\n    p:get('counter')\nend)\n```\n\n### Variadic commands\n\nSome commands such as RPUSH, SADD, SINTER and others have been improved in Redis 2.4\nto accept a list of values or keys depending on the nature of the command. Sometimes\nit can be useful to pass these arguments as a list in a table, but since redis-lua does\nnot currently do anything to handle such a case you can use `unpack()` albeit with a\nlimitation on the maximum number of items which is defined in Lua by LUAI_MAXCSTACK\n(the default on Lua 5.1 is set to `8000`, see `luaconf.h`):\n\n```lua\nlocal values = { 'value1', 'value2', 'value3' }\nclient:rpush('list', unpack(values))\n\n-- the previous line has the same effect of the following one:\nclient:rpush('list', 'value1', 'value2', 'value3')\n```\n\n### Leverage Redis MULTI / EXEC transaction (Redis \u003e 2.0)\n\n``` lua\nlocal replies = client:transaction(function(t)\n    t:incrby('counter', 10)\n    t:incrby('counter', 30)\n    t:get('counter')\nend)\n```\n\n### Leverage WATCH / MULTI / EXEC for check-and-set (CAS) operations (Redis \u003e 2.2)\n\n``` lua\nlocal options = { watch = \"key_to_watch\", cas = true, retry = 2 }\nlocal replies = client:transaction(options, function(t)\n    local val = t:get(\"key_to_watch\")\n    t:multi()\n    t:set(\"akey\", val)\n    t:set(\"anotherkey\", val)\nend)\n```\n\n### Get useful information from the server ###\n\n``` lua\nfor k,v in pairs(client:info()) do\n    print(k .. ' =\u003e ' .. tostring(v))\nend\n--[[\nredis_git_dirty =\u003e 0\nredis_git_sha1 =\u003e aaed0894\nprocess_id =\u003e 23115\nvm_enabled =\u003e 0\nhash_max_zipmap_entries =\u003e 64\nexpired_keys =\u003e 9\nchanges_since_last_save =\u003e 2\nrole =\u003e master\nlast_save_time =\u003e 1283621624\nused_memory =\u003e 537204\nbgsave_in_progress =\u003e 0\nredis_version =\u003e 2.0.0\nmultiplexing_api =\u003e epoll\ntotal_connections_received =\u003e 314\ndb0 =\u003e {keys=3,expires=0}\npubsub_patterns =\u003e 0\nused_memory_human =\u003e 524.61K\npubsub_channels =\u003e 0\nuptime_in_seconds =\u003e 1033\nconnected_slaves =\u003e 0\nconnected_clients =\u003e 1\nbgrewriteaof_in_progress =\u003e 0\nblocked_clients =\u003e 0\narch_bits =\u003e 32\ntotal_commands_processed =\u003e 3982\nhash_max_zipmap_value =\u003e 512\ndb15 =\u003e {keys=1,expires=0}\nuptime_in_days =\u003e 0\n]]\n```\n\n## Dependencies ##\n\n- [Lua 5.1 and 5.2](http://www.lua.org/) or [LuaJIT 2.0](http://luajit.org/)\n- [LuaSocket 2.0](http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/)\n- [Telescope](http://telescope.luaforge.net/) (required to run the test suite)\n\n## Links ##\n\n### Project ###\n- [Source code](http://github.com/nrk/redis-lua/)\n- [Issue tracker](http://github.com/nrk/redis-lua/issues)\n\n### Related ###\n- [Redis](http://redis.io/)\n- [Git](http://git-scm.com/)\n\n## Authors ##\n\n[Daniele Alessandri](mailto:suppakilla@gmail.com)\n\n### Contributors ###\n\n[Leo Ponomarev](http://github.com/slact/)\n\n## License ##\n\nThe code for redis-lua is distributed under the terms of the MIT/X11 license (see LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnrk%2Fredis-lua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnrk%2Fredis-lua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnrk%2Fredis-lua/lists"}