Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wankdanker/node-redis-key
https://github.com/wankdanker/node-redis-key
Last synced: 14 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/wankdanker/node-redis-key
- Owner: wankdanker
- Created: 2015-10-14T18:29:26.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-23T14:29:27.000Z (about 9 years ago)
- Last Synced: 2024-12-17T08:26:11.203Z (21 days ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
redis-key
---------Redis key generator / function argument joiner
This module is basically a shortcut for:
```js
Array.prototype.slice.call(arguments).join(separator);
```install
-------```bash
npm install redis-key
```example
-------```js
var rk = require('redis-key');//default separator is ':'
var key = rk('product-collection', 'company', 'price-level');
//key = "product-collection:company:price-level"
```### Setting a default separator
```js
var rk = require('redis-key').defaults('/');//now the separator is '/'
var key = rk('part', 1, 3);
//key = "part/1/3"
```api
---### .defaults([separator, [prefix]])
* separator - [string] the character[s] to put between the tokens that make up your key (default ':')
* prefix - [string] an additional token that is prefixed to the keymotivation
----------I've been generating redis keys like this:
```js
var key = ['part1', var1, var2, var3].join(':');
```I thought it would be more concise to be able to do this:
```js
var key = k('part1', var1, var2, var3);
```And if my math is correct, it is more concise by 9 whole characters. Joy.
license
-------MIT