{"id":19136980,"url":"https://github.com/singcl/node-redis","last_synced_at":"2026-04-19T02:02:42.592Z","repository":{"id":94726413,"uuid":"126581039","full_name":"singcl/node-redis","owner":"singcl","description":"Redis cluster construction for building with nodejs.","archived":false,"fork":false,"pushed_at":"2018-08-22T04:31:20.000Z","size":4330,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-03T13:19:28.757Z","etag":null,"topics":["acl","nodejs","redis-cluster","ruby"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/singcl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-24T08:42:03.000Z","updated_at":"2018-08-22T04:31:22.000Z","dependencies_parsed_at":"2023-05-05T15:02:31.731Z","dependency_job_id":null,"html_url":"https://github.com/singcl/node-redis","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/singcl%2Fnode-redis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/singcl%2Fnode-redis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/singcl%2Fnode-redis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/singcl%2Fnode-redis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/singcl","download_url":"https://codeload.github.com/singcl/node-redis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240215512,"owners_count":19766431,"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","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":["acl","nodejs","redis-cluster","ruby"],"created_at":"2024-11-09T06:36:02.810Z","updated_at":"2025-11-13T02:02:29.781Z","avatar_url":"https://github.com/singcl.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 如何使用Ruby 创建Redis 集群。\n\n### Redis cluster construction for building with nodejs.\n \n### 使用\n\n*环境配置：Ruby 和 Ruby Gem*\n\n- `npm run installs` 将6个redis节点配置成windows 服务. 这样每次就会开机自启没用每次都是手动开启。\n- `npm run start` 启动这个6个redis 节点服务。\n- `npm run stop` 结束这个6个redis 节点服务。\n- `npm run uninstalls` 卸载这6个之前配置的windows服务。\n\n- `npm run cluster` 将上面6个redis 节点连接成集群模式。\n\n*项目中redis文件夹是对官方redis安装包的一份拷贝。其中7000-7005文件夹是我自己添加的*\n\n### EXAMPLE\n\n在`example` 目录下分别给出通过ruby和js链接到redis集群进行操作的简单示例。\n\n#### NODE.JS\n```js\n// ioredis 链接到redis 集群\n// @singcl/acl 对集群进行Acl权限数据读写\n\nvar Redis = require('ioredis')\nvar Acl = require('@singcl/acl')\n\nvar redis = new Redis.Cluster([{\n    port: 7000,\n    host: '127.0.0.1'\n  }, {\n    port: 7001,\n    host: '127.0.0.1'\n  }, {\n    port: 7002,\n    host: '127.0.0.1'\n}]);\n\n\n//var redis = new Redis()\n\n// cluster.hmset([\"key\", \"test keys 1\", \"test val 1\", \"test keys 2\", \"test val 2\"], function (err, res) {})\n// redis.sadd(\"hashsss\", \"some value\");\n\nvar acl = new Acl(new Acl.redisBackend(redis, 'dap_acl'));\n\n\n// acl.removeUserRoles('joed', 'member', function(err) {\n  //   console.log(err)\n  // })\n\nacl.allow('member', '/api/admin/analysis/product/url/download/id', ['post'])    // 数据下载\nacl.allow('member', '/api/admin/analysis/download/plan/success', ['get'])       // URL下载\n\nacl.addUserRoles('admin', 'member', function(err) {\n    console.log(err)\n})\n\n// acl.removeUserRoles('admin', 'member')\n\nacl.isAllowed('admin', '/api/admin/analysis/product/url/download/id', 'post', function(err, res){\n  console.log(err)\n  if(res){\n      console.log(\"User admin is allowed to view blogs\")\n  }\n})\nacl.whatResources('member', function(err, r) {\n  console.log(r)\n})\n```\n\n#### RUBY\n```rb\nrequire './cluster'\n\nif ARGV.length != 2\n    startup_nodes = [\n        {:host =\u003e \"127.0.0.1\", :port =\u003e 7001},\n        {:host =\u003e \"127.0.0.1\", :port =\u003e 6789}\n    ]\nelse\n    startup_nodes = [\n        {:host =\u003e ARGV[0], :port =\u003e ARGV[1].to_i}\n    ]\nend\n\nrc = RedisCluster.new(startup_nodes,32,:timeout =\u003e 0.1)\n\nlast = false\n\nwhile not last\n    begin\n        last = rc.get(\"__last__\")\n        last = 0 if !last\n    rescue =\u003e e\n        puts \"error #{e.to_s}\"\n        sleep 1\n    end\nend\n\n((last.to_i+1)..1000000000).each{|x|\n    begin\n        rc.set(\"foo#{x}\",x)\n        puts rc.get(\"foo#{x}\")\n        rc.set(\"__last__\",x)\n    rescue =\u003e e\n        puts \"error #{e.to_s}\"\n    end\n    sleep 0.1\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsingcl%2Fnode-redis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsingcl%2Fnode-redis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsingcl%2Fnode-redis/lists"}