{"name":"cluster-key-slot","version":"1.1.2","description":"Generates CRC hashes for strings - for use by node redis clients to determine key slots.","main":"lib/index.js","types":"index.d.ts","scripts":{"benchmark":"node ./benchmark","posttest":"eslint ./lib && npm run coveralls","coveralls":"cat ./coverage/lcov.info | coveralls","test":"node ./node_modules/istanbul/lib/cli.js cover --preserve-comments ./node_modules/mocha/bin/_mocha -- -R spec","coverage:check":"node ./node_modules/istanbul/lib/cli.js check-coverage --branch 100 --statement 100"},"repository":{"type":"git","url":"git+https://github.com/Salakar/cluster-key-slot.git"},"keywords":["redis","hash","crc","slot","calc","javascript","node","node_redis","ioredis"],"engines":{"node":">=0.10.0"},"devDependencies":{"benchmark":"^2.1.0","codeclimate-test-reporter":"^0.3.1","coveralls":"^2.11.9","eslint":"^3.5.0","eslint-config-airbnb-base":"^7.1.0","eslint-plugin-import":"^1.8.0","istanbul":"^0.4.0","mocha":"^3.0.2"},"author":{"name":"Mike Diarmid","email":"mike.diarmid@gmail.com","url":"http://github.com/Salakar/"},"license":"Apache-2.0","bugs":{"url":"https://github.com/Salakar/cluster-key-slot/issues"},"homepage":"https://github.com/Salakar/cluster-key-slot#readme","directories":{"test":"test","lib":"lib"},"gitHead":"992ae4c2599dd8ff985930df1013af4ab94fe7e1","_id":"cluster-key-slot@1.1.2","_nodeVersion":"18.3.0","_npmVersion":"8.11.0","dist":{"integrity":"sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA==","shasum":"88ddaa46906e303b5de30d3153b7d9fe0a0c19ac","tarball":"http://registry-npm.ywwl.com/cluster-key-slot/download/cluster-key-slot-1.1.2.tgz","fileCount":6,"unpackedSize":12180,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD/Ada8wcVcaogcEQg9d09m82ELUYSHUKYHtr0zkJZJOgIhAMW+kRVniuTHNB7CaQWC/PiX/IN8fnkQwSdhGoptBS5b"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjYScaACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqSiQ/9FR20HhAWXiuDvTFa0RwNsGpCkqDRBem94x/xpIoVhDp7we8r\r\nro0n4wVVycEz+Pag4ZKOIzHU/bcwDi02tHtqc1Taaq4DLQcdlNfjcpF8wtOn\r\ntrpqR4vb/yWIgdL14uvEkPY5IKzWAXDdC97ywehccNjoMZZWFsIdVoyn9UCW\r\n19sEDF0WZiSc2fDcGfev2e6B3+2DfCnO4qVwCJCXgv6N2ct+Xgiw36kkbS18\r\nYKBjrvPqGB9E0X79sUizSNeYbCfdl+X9gt/XGoRZ9FHMYYyB+VPQrHTACpSJ\r\n0VfPgetSLMl9PJha09sT1XxsUzR5amWKg16N8OXaJ2IFShzCrKBSLkdLxb6Q\r\n+GKEOy3OvkPA5QUo0GdIpSforUHNNcHiOKKE4EKC9xe/gWutkF6wNWXDYI/i\r\nVUEwUZVPoFm48i0JC3X+hFxdRSDhVWgJp6x6nTbRs7lO+Wx0Ui+KteLiO64a\r\nlE3TDtAx1rrqxR+rcRpDgO2RLCD+qQIKS18YLVcaoZrtJKEDh64ocWyyfvzV\r\nTiavdeZfYBqgCYEPVoZdNJ4Osamuu7WfEValHZtAGVIMQk2F+35nVjfvU0+w\r\nMjA4qh1yrNurJME9aKKevhD840CYTH4xTnSEGq7/6F7VZbj73pzCPzug1etQ\r\nWmli/L+bMDiFBKvZRfker9DdUPY0NyXVnJ4=\r\n=1h/3\r\n-----END PGP SIGNATURE-----\r\n","size":5253,"noattachment":false,"key":"/cluster-key-slot/-/cluster-key-slot-1.1.2.tgz"},"_npmUser":{"name":"salakar","email":"mike.diarmid@gmail.com"},"maintainers":[{"name":"salakar","email":"mike.diarmid@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cluster-key-slot_1.1.2_1667311386149_0.6830058681166773"},"_hasShrinkwrap":false,"readme":"[![Coverage Status](https://coveralls.io/repos/github/Salakar/cluster-key-slot/badge.svg?branch=master)](https://coveralls.io/github/Salakar/cluster-key-slot?branch=master)\n![Downloads](https://img.shields.io/npm/dt/cluster-key-slot.svg)\n[![npm version](https://img.shields.io/npm/v/cluster-key-slot.svg)](https://www.npmjs.com/package/cluster-key-slot)\n[![dependencies](https://img.shields.io/david/Salakar/cluster-key-slot.svg)](https://david-dm.org/Salakar/cluster-key-slot)\n[![License](https://img.shields.io/npm/l/cluster-key-slot.svg)](/LICENSE)\n<a href=\"https://twitter.com/mikediarmid\"><img src=\"https://img.shields.io/twitter/follow/mikediarmid.svg?style=social&label=Follow\" alt=\"Follow on Twitter\"></a>\n\n# Redis Key Slot Calculator\n\nA high performance redis cluster key slot calculator for node redis clients e.g. [node_redis](https://github.com/NodeRedis/node_redis), [ioredis](https://github.com/luin/ioredis) and [redis-clustr](https://github.com/gosquared/redis-clustr/).\n\nThis also handles key tags such as `somekey{actualTag}`.\n\n## Install\n\nInstall with [NPM](https://npmjs.org/):\n\n```\nnpm install cluster-key-slot --save\n```\n\n## Usage\n\n```js\nconst calculateSlot = require('cluster-key-slot');\nconst calculateMultipleSlots = require('cluster-key-slot').generateMulti;\n\n// ...\n\n// a single slot number\nconst slot = calculateSlot('test:key:{butOnlyThis}redis');\n// Buffer is also supported\nconst anotherSlot = calculateSlot(Buffer.from([0x7b, 0x7d, 0x2a]));\n\n// multiple keys - multi returns a single key slot number, returns -1 if any\n// of the keys does not match the base slot number (base is defaulted to first keys slot)\n// This is useful to quickly determine a singe slot for multi keys operations.\nconst slotForRedisMulti = calculateMultipleSlots([\n  'test:key:{butOnlyThis}redis',\n  'something:key45:{butOnlyThis}hello',\n  'example:key46:{butOnlyThis}foobar',\n]);\n```\n\n## Benchmarks\n\n`OLD` in these benchmarks refers to the `ioredis` crc calc and many of the other calculators that use `Buffer`.\n\n```text\nnode -v                                                                                                                                                                                                ✔  16.38G RAM  10:29:07\nv10.15.3\n\nNEW tags x 721,445 ops/sec ±0.44% (90 runs sampled)\nOLD tags x 566,777 ops/sec ±0.97% (96 runs sampled)\nNEW without tags x 2,054,845 ops/sec ±1.77% (92 runs sampled)\nOLD without tags x 865,839 ops/sec ±0.43% (96 runs sampled)\nNEW without tags singular x 6,354,097 ops/sec ±1.25% (94 runs sampled)\nOLD without tags singular x 4,012,250 ops/sec ±0.96% (94 runs sampled)\nNEW tags (Buffer) x 552,346 ops/sec ±1.35% (92 runs sampled)\n```\n\n","publish_time":1667311386331,"_cnpm_publish_time":1667311386331,"dist-tags":{"latest":"1.1.2"}}