Skip to content

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
freshlogic committed Sep 30, 2017
1 parent ce55f5e commit dcc3d3b
Showing 1 changed file with 55 additions and 5 deletions.
60 changes: 55 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,22 @@ pettyCache.bulkFetch(['a', 'b', 'c', 'd'], function(keys, callback) {
**Options**
```javascript
```
{
ttl: 30000 // How long it should take for the cache entry to expire in milliseconds. Defaults to a random value between 30000 and 60000 (for jitter).
}
```
```
{
// TTL can optional be specified with a range to pick a random value between `min` and `max` (for jitter).
ttl: {
min: 5000,
max: 10000
}
}
```
### pettyCache.bulkGet(keys, callback)
Attempts to retrieve the values of the keys specified in the `keys` array. Returns a key-value hash of all specified keys with either the corresponding values from cache or `undefined` if a key was not found.
Expand Down Expand Up @@ -109,12 +119,22 @@ pettyCache.set({ key1: 'one', key2: 2, key3: 'three' }, function(err) {
**Options**
```javascript
```
{
ttl: 30000 // How long it should take for the cache entries to expire in milliseconds. Defaults to a random value between 30000 and 60000 (for jitter).
}
```
```
{
// TTL can optional be specified with a range to pick a random value between `min` and `max` (for jitter).
ttl: {
min: 5000,
max: 10000
}
}
```
### pettyCache.fetch(key, cacheMissFunction, [options,] callback)
Attempts to retrieve the value from cache at the specified key. If it doesn't exist, it executes the specified cacheMissFunction that takes two parameters: an error and a value. `cacheMissFunction` should retrieve the expected value for the key from another source and pass it to the given callback. Either way, the resulting error or value is passed to `callback`.
Expand All @@ -133,12 +153,22 @@ pettyCache.fetch('key', function(callback) {
**Options**
```javascript
```
{
ttl: 30000 // How long it should take for the cache entry to expire in milliseconds. Defaults to a random value between 30000 and 60000 (for jitter).
}
```
```
{
// TTL can optional be specified with a range to pick a random value between `min` and `max` (for jitter).
ttl: {
min: 5000,
max: 10000
}
}
```
### pettyCache.get(key, callback)
Attempts to retrieve the value from cache at the specified key. Returns `null` if the key doesn't exist.
Expand Down Expand Up @@ -170,12 +200,22 @@ pettyCache.patch('key', { a: 1 }, function(callback) {
**Options**
```javascript
```
{
ttl: 30000 // How long it should take for the cache entry to expire in milliseconds. Defaults to a random value between 30000 and 60000 (for jitter).
}
```
```
{
// TTL can optional be specified with a range to pick a random value between `min` and `max` (for jitter).
ttl: {
min: 5000,
max: 10000
}
}
```
### pettyCache.set(key, value, [options,] callback)
Unconditionally sets a value for a given key.
Expand All @@ -192,12 +232,22 @@ pettyCache.set('key', { a: 'b' }, function(err) {
**Options**
```javascript
```
{
ttl: 30000 // How long it should take for the cache entry to expire in milliseconds. Defaults to a random value between 30000 and 60000 (for jitter).
}
```
```
{
// TTL can optional be specified with a range to pick a random value between `min` and `max` (for jitter).
ttl: {
min: 5000,
max: 10000
}
}
```
## Mutex
### pettyCache.mutex.lock(key, [options, [callback]])
Expand Down

0 comments on commit dcc3d3b

Please sign in to comment.