https://github.com/pine/keyfac
:key: Declare cache key generator
https://github.com/pine/keyfac
Last synced: 4 months ago
JSON representation
:key: Declare cache key generator
- Host: GitHub
- URL: https://github.com/pine/keyfac
- Owner: pine
- License: mit
- Created: 2017-10-12T06:28:28.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-03-27T19:48:26.000Z (almost 7 years ago)
- Last Synced: 2025-10-11T02:20:17.078Z (4 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/keyfac
- Size: 34.2 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
keyfac
------
[](https://nodei.co/npm/keyfac/)
[](https://www.npmjs.org/package/keyfac)
[](https://travis-ci.org/pine/keyfac)
[](https://ci.appveyor.com/project/pine/keyfac/branch/master)
[](https://david-dm.org/pine/keyfac)
[](https://david-dm.org/pine/keyfac#info=devDependencies)
:key: Declare cache key generator inspired by [Cache::Keys::DSL](https://github.com/karupanerura/Cache-Keys-DSL).
## Requirements
- Node v4 or later
## Getting started
```
$ yarn add keyfac
```
or
```
$ npm install --save keyfac
```
## Usage
```javascript
const { key, keygen } = requure('keyfac')
// Simple key
const userCountKey = key('user_count')
console.log(userCountKey) // => key_for_user_count
// Key with User ID
const userNameKey = keygen('user_name')
console.log(userNameKey(1)) // => gen_key_for_user_name_1
```
See also [test.js](test.js).
## References
### `key(... items)`
Create simple key.
### `keygen(... items)`
Create key generator function with base arguments.
## License
MIT © Pine Mizune