Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit 4087d1f

Browse files
committed
Initial commit
0 parents  commit 4087d1f

32 files changed

+9154
-0
lines changed

.babelrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"presets": ["flow", ["env", {
3+
"targets": {
4+
"browsers": [">1%", "last 4 versions", "Firefox ESR", "not ie < 9"]
5+
}
6+
}]],
7+
"plugins": ["transform-react-jsx", "transform-class-properties"]
8+
}

.flowconfig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[ignore]
2+
.*/node_modules/.*
3+
4+
[include]
5+
6+
[libs]
7+
8+
[options]
9+
suppress_comment=.*\\$FlowFixMe
10+
esproposal.class_instance_fields=enable
11+
esproposal.class_static_fields=enable
12+
13+
[lints]
14+
all=error
15+
16+
[strict]
17+
nonstrict-import
18+
unclear-type
19+
unsafe-getters-setters
20+
untyped-import
21+
untyped-type-import
22+
sketchy-null

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.swp
2+
*~
3+
*.iml
4+
.*.haste_cache.*
5+
.DS_Store
6+
.idea
7+
npm-debug.log
8+
node_modules
9+
dist

.npmignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*.swp
2+
*~
3+
*.iml
4+
.*.haste_cache.*
5+
.DS_Store
6+
.idea
7+
.babelrc
8+
.eslintrc
9+
npm-debug.log
10+
lib

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"trailingComma": "es5",
3+
"singleQuote": true
4+
}

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: node_js
2+
node_js:
3+
- 8
4+
script:
5+
- node --version
6+
- yarn --version
7+
- yarn run test
8+
notifications:
9+
email: false
10+
cache:
11+
yarn: true
12+
directories:
13+
- node_modules

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017 Maximilian Stoiber
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# `redis-tag-cache`
2+
3+
Cache and invalidate records in Redis with tags.
4+
5+
## Installation
6+
7+
```sh
8+
yarn add redis-tag-cache
9+
# or
10+
npm install redis-tag-cache
11+
```
12+
13+
## Demo Usage
14+
15+
```js
16+
import TagCache from 'redis-tag-cache';
17+
18+
const cache = new TagCache();
19+
20+
/*
21+
* Cache some records tagged with IDs
22+
*/
23+
24+
// Store two posts by the same author
25+
await cache.set('post:id-123', { id: 'id-123', title: 'Hello world', author: 'user-123' }, ['id-123', 'user-123']);
26+
await cache.set('post:id-234', { id: 'id-234', title: 'Hello world again', author: 'user-123' }, ['id-234', 'user-123']);
27+
// And a third post by a different author
28+
await cache.set('post:id-345', { id: 'id-345', title: 'Hello world again', author: 'user-234' }, ['id-345', 'user-234']);
29+
30+
/*
31+
* Retrieve records by their ID
32+
*/
33+
34+
console.log(await cache.get('post:id-234')) // => { id: 'id-234', title: 'Hello world again', author: 'user-123' }
35+
36+
/*
37+
* Invalidate records by their tags
38+
*/
39+
40+
// Invalidate all records tagged with `user-123`
41+
await cache.invalidate(['user-123']);
42+
console.log(await cache.get('post:id-123')) // => null
43+
console.log(await cache.get('post:id-234')) // => null
44+
// The third post not tagged with `user-123` is still around!
45+
console.log(await cache.get('post:id-345')) // => { id: 'id-345', title: 'Hello world again', author: 'user-234' }
46+
```
47+
48+
## API
49+
50+
### Base class
51+
52+
```JS
53+
const cache = new TagCache(options, ioredisOptions);
54+
```
55+
56+
#### `options`
57+
58+
Options can be an object containing any of the following keys:
59+
60+
- `defaultTimeout`: number of seconds until records expire even if not invalidated
61+
62+
Example:
63+
64+
```JS
65+
const cache = new TagCache({
66+
defaultTimeout: 86400,
67+
});
68+
```
69+
70+
#### `ioredisOptions`
71+
72+
Any [`ioredis` option](https://github.com/luin/ioredis/blob/master/API.md#new-redisport-host-options), this object is directly passed through to `new Redis(ioredisOptions)`.
73+
74+
Example:
75+
76+
```JS
77+
const cache = new TagCache(options, {
78+
keyPrefix: 'my-cache', // Recommended: set a keyprefix for all keys stored via the cache
79+
port: 6379,
80+
host: 'redis-service.com',
81+
password: 'password',
82+
});
83+
```
84+
85+
## License
86+
87+
Licensed under the MIT License, Copyright ©️ 2018 Maximilian Stoiber. See [LICENSE.md](LICENSE.md) for more information.

flow-typed/npm/babel-cli_vx.x.x.js

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
// flow-typed signature: 0b1433c9c4ad723e7948a8a9d4a096b9
2+
// flow-typed version: <<STUB>>/babel-cli_v^6.26.0/flow_v0.55.0
3+
4+
/**
5+
* This is an autogenerated libdef stub for:
6+
*
7+
* 'babel-cli'
8+
*
9+
* Fill this stub out by replacing all the `any` types.
10+
*
11+
* Once filled out, we encourage you to share your work with the
12+
* community by sending a pull request to:
13+
* https://github.com/flowtype/flow-typed
14+
*/
15+
16+
declare module 'babel-cli' {
17+
declare module.exports: any;
18+
}
19+
20+
/**
21+
* We include stubs for each file inside this npm package in case you need to
22+
* require those files directly. Feel free to delete any files that aren't
23+
* needed.
24+
*/
25+
declare module 'babel-cli/bin/babel-doctor' {
26+
declare module.exports: any;
27+
}
28+
29+
declare module 'babel-cli/bin/babel-external-helpers' {
30+
declare module.exports: any;
31+
}
32+
33+
declare module 'babel-cli/bin/babel-node' {
34+
declare module.exports: any;
35+
}
36+
37+
declare module 'babel-cli/bin/babel' {
38+
declare module.exports: any;
39+
}
40+
41+
declare module 'babel-cli/lib/_babel-node' {
42+
declare module.exports: any;
43+
}
44+
45+
declare module 'babel-cli/lib/babel-external-helpers' {
46+
declare module.exports: any;
47+
}
48+
49+
declare module 'babel-cli/lib/babel-node' {
50+
declare module.exports: any;
51+
}
52+
53+
declare module 'babel-cli/lib/babel/dir' {
54+
declare module.exports: any;
55+
}
56+
57+
declare module 'babel-cli/lib/babel/file' {
58+
declare module.exports: any;
59+
}
60+
61+
declare module 'babel-cli/lib/babel/index' {
62+
declare module.exports: any;
63+
}
64+
65+
declare module 'babel-cli/lib/babel/util' {
66+
declare module.exports: any;
67+
}
68+
69+
// Filename aliases
70+
declare module 'babel-cli/bin/babel-doctor.js' {
71+
declare module.exports: $Exports<'babel-cli/bin/babel-doctor'>;
72+
}
73+
declare module 'babel-cli/bin/babel-external-helpers.js' {
74+
declare module.exports: $Exports<'babel-cli/bin/babel-external-helpers'>;
75+
}
76+
declare module 'babel-cli/bin/babel-node.js' {
77+
declare module.exports: $Exports<'babel-cli/bin/babel-node'>;
78+
}
79+
declare module 'babel-cli/bin/babel.js' {
80+
declare module.exports: $Exports<'babel-cli/bin/babel'>;
81+
}
82+
declare module 'babel-cli/index' {
83+
declare module.exports: $Exports<'babel-cli'>;
84+
}
85+
declare module 'babel-cli/index.js' {
86+
declare module.exports: $Exports<'babel-cli'>;
87+
}
88+
declare module 'babel-cli/lib/_babel-node.js' {
89+
declare module.exports: $Exports<'babel-cli/lib/_babel-node'>;
90+
}
91+
declare module 'babel-cli/lib/babel-external-helpers.js' {
92+
declare module.exports: $Exports<'babel-cli/lib/babel-external-helpers'>;
93+
}
94+
declare module 'babel-cli/lib/babel-node.js' {
95+
declare module.exports: $Exports<'babel-cli/lib/babel-node'>;
96+
}
97+
declare module 'babel-cli/lib/babel/dir.js' {
98+
declare module.exports: $Exports<'babel-cli/lib/babel/dir'>;
99+
}
100+
declare module 'babel-cli/lib/babel/file.js' {
101+
declare module.exports: $Exports<'babel-cli/lib/babel/file'>;
102+
}
103+
declare module 'babel-cli/lib/babel/index.js' {
104+
declare module.exports: $Exports<'babel-cli/lib/babel/index'>;
105+
}
106+
declare module 'babel-cli/lib/babel/util.js' {
107+
declare module.exports: $Exports<'babel-cli/lib/babel/util'>;
108+
}

0 commit comments

Comments
 (0)