Skip to content

Commit a513b71

Browse files
authored
Apply common project tweaks (round 2) (#90)
* Add dependency-check * Add Donate section and badges to README.md * Run hallmark * Tweak badges and links in README.md * Remove NodeICO badge * Remove NodeICO badge * More tweaks
1 parent 251fb93 commit a513b71

File tree

3 files changed

+52
-17
lines changed

3 files changed

+52
-17
lines changed

Diff for: CONTRIBUTORS.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
| :-------------------------- | :----------------------------------------------------- | :-------------------------------------------------------------- |
55
| **Lars-Magnus Skog** | [**@ralphtheninja**](https://github.com/ralphtheninja) | [**@ralph@social.weho.st**](https://social.weho.st/@ralph) |
66
| **Rod Vagg** | [**@rvagg**](https://github.com/rvagg) | [**@rvagg@twitter**](https://twitter.com/rvagg) |
7-
| **Vincent Weevers** | [**@vweevers**](https://github.com/vweevers) | [**@vweevers@twitter**](https://twitter.com/vweevers) |
87
| **Josh Duff** | [**@TehShrike**](https://github.com/TehShrike) | |
98
| **Matteo Collina** | [**@mcollina**](https://github.com/mcollina) | [**@matteocollina@twitter**](https://twitter.com/matteocollina) |
109
| **Dean Landolt** | [**@deanlandolt**](https://github.com/deanlandolt) | |
10+
| **Vincent Weevers** | [**@vweevers**](https://github.com/vweevers) | [**@vweevers@twitter**](https://twitter.com/vweevers) |
1111
| **Mathias Buus** | [**@mafintosh**](https://github.com/mafintosh) | [**@mafintosh@twitter**](https://twitter.com/mafintosh) |
1212
| **José F. Romaniello** | | |
1313
| **Max Ogden** | [**@maxogden**](https://github.com/maxogden) | [**@maxogden@twitter**](https://twitter.com/maxogden) |

Diff for: README.md

+47-15
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,33 @@
1-
# Level TTL
1+
# level-ttl
22

3-
<img alt="LevelDB Logo" height="100" src="http://leveldb.org/img/logo.svg">
3+
> Add a `ttl` (time-to-live) option to [`levelup`][levelup] for `put()` and `batch()`.
44
5-
**Add a `'ttl'` (time-to-live) option to LevelUP for `put()` and `batch()`**
6-
7-
[![Build Status](https://travis-ci.org/Level/level-ttl.svg?branch=master)](https://travis-ci.org/Level/level-ttl)
8-
[![Greenkeeper badge](https://badges.greenkeeper.io/Level/level-ttl.svg)](https://greenkeeper.io/)
9-
[![dependencies](https://david-dm.org/Level/level-ttl.svg)](https://david-dm.org/level/level-ttl)
5+
[![level badge][level-badge]](https://github.com/Level/awesome)
6+
[![npm](https://img.shields.io/npm/v/level-ttl.svg?label=&logo=npm)](https://www.npmjs.com/package/level-ttl)
7+
[![Node version](https://img.shields.io/node/v/level-ttl.svg)](https://www.npmjs.com/package/level-ttl)
8+
[![Travis](https://img.shields.io/travis/Level/level-ttl.svg?logo=travis&label=)](https://travis-ci.org/Level/level-ttl)
109
[![Coverage Status](https://coveralls.io/repos/github/Level/level-ttl/badge.svg)](https://coveralls.io/github/Level/level-ttl)
1110
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
11+
[![npm](https://img.shields.io/npm/dm/level-ttl.svg?label=dl)](https://www.npmjs.com/package/level-ttl)
12+
[![Backers on Open Collective](https://opencollective.com/level/backers/badge.svg?color=orange)](#backers)
13+
[![Sponsors on Open Collective](https://opencollective.com/level/sponsors/badge.svg?color=orange)](#sponsors)
14+
15+
## Table of Contents
16+
17+
<details><summary>Click to expand</summary>
18+
19+
- [Usage](#usage)
20+
- [Contributing](#contributing)
21+
- [Donate](#donate)
22+
- [License](#license)
1223

13-
[![NPM](https://nodei.co/npm/level-ttl.png?downloads=true&downloadRank=true)](https://nodei.co/npm/level-ttl/)
14-
[![NPM](https://nodei.co/npm-dl/level-ttl.png?months=6&height=3)](https://nodei.co/npm/level-ttl/)
24+
</details>
1525

16-
Augment LevelUP to handle a new `'ttl'` option on `put()` and `batch()` that specifies the number of milliseconds an entry should remain in the data store. After the TTL, the entry will be automatically cleared for you.
26+
## Usage
1727

18-
Requires [LevelUP](https://github.com/rvagg/node-levelup), [Level](https://github.com/level/level) or [level-hyper](https://github.com/Level/level-hyper) to be installed separately.
28+
Augment `levelup` to handle a new `'ttl'` option on `put()` and `batch()` that specifies the number of milliseconds an entry should remain in the data store. After the TTL, the entry will be automatically cleared for you.
29+
30+
Requires [`levelup`][levelup], [`level`][level] or [`level-hyper`][level-hyper] to be installed separately.
1931

2032
**_Note 1: Version 1.0.0 data stores are not backward compatible with previous versions. If you have unexpired entries in a data store managed by pre-1.0.0, don't expect them to expire if you upgrade to 1.0.0+._** _This is due to a level-sublevel change. It is also recommended that you only use level-sublevel 6.0.0+ with level-ttl._
2133

@@ -43,14 +55,14 @@ db.batch([
4355

4456
If you put the same entry twice, you **refresh** the TTL to the _last_ put operation. In this way you can build utilities like [session managers](https://github.com/rvagg/node-level-session/) for your web application where the user's session is refreshed with each visit but expires after a set period of time since their last visit.
4557

46-
Alternatively, for a lower write-footprint you can use the `ttl()` method that is added to your LevelUP instance which can serve to insert or update a ttl for any given key in the database (even if that key doesn't exist but may in the future! Crazy!).
58+
Alternatively, for a lower write-footprint you can use the `ttl()` method that is added to your `levelup` instance which can serve to insert or update a ttl for any given key in the database (even if that key doesn't exist but may in the future! Crazy!).
4759

4860
```js
4961
db.put('foo', 'bar', function (err) { /* .. */ })
5062
db.ttl('foo', 1000 * 60 * 60, function (err) { /* .. */ })
5163
```
5264

53-
**Level TTL** uses an internal scan every 10 seconds by default, this limits the available resolution of your TTL values, possibly delaying a delete for up to 10 seconds. The resolution can be tuned by passing the `'checkFrequency'` option to the `ttl()` initialiser.
65+
`level-ttl` uses an internal scan every 10 seconds by default, this limits the available resolution of your TTL values, possibly delaying a delete for up to 10 seconds. The resolution can be tuned by passing the `'checkFrequency'` option to the `ttl()` initialiser.
5466

5567
```js
5668
var db = levelup('/tmp/foo.db')
@@ -60,7 +72,7 @@ db = ttl(db, { checkFrequency: 1000 })
6072
/* .. */
6173
```
6274

63-
Of course, a scan takes some resources, particularly on a data store that makes heavy use of TTLs. If you don't require high accuracy for actual deletions then you can increase the `'checkFrequency'`. Note though that a scan only involves invoking a LevelUP ReadStream that returns _only the entries due to expire_, so it doesn't have to manually check through all entries with a TTL. As usual, it's best to not do too much tuning until you have you have something worth tuning!
75+
Of course, a scan takes some resources, particularly on a data store that makes heavy use of TTLs. If you don't require high accuracy for actual deletions then you can increase the `'checkFrequency'`. Note though that a scan only involves invoking a `levelup` ReadStream that returns _only the entries due to expire_, so it doesn't have to manually check through all entries with a TTL. As usual, it's best to not do too much tuning until you have you have something worth tuning!
6476

6577
### Default TTL
6678

@@ -109,7 +121,7 @@ For more examples on this please check the tests involving `level-sublevel`.
109121

110122
### Shutting down
111123

112-
**Level TTL** uses a timer to regularly check for expiring entries (don't worry, the whole data store isn't scanned, it's very efficient!). The `db.close()` method is automatically wired to stop the timer but there is also a more explicit <b><code>db.stop()</code></b> method that will stop the timer and not pass on to a `close()` underlying LevelUP instance.
124+
`level-ttl` uses a timer to regularly check for expiring entries (don't worry, the whole data store isn't scanned, it's very efficient!). The `db.close()` method is automatically wired to stop the timer but there is also a more explicit <b><code>db.stop()</code></b> method that will stop the timer and not pass on to a `close()` underlying `levelup` instance.
113125

114126
## Contributing
115127

@@ -119,6 +131,26 @@ For more examples on this please check the tests involving `level-sublevel`.
119131
120132
See the [Contribution Guide](https://github.com/Level/community/blob/master/CONTRIBUTING.md) for more details.
121133

134+
## Donate
135+
136+
To sustain [`Level`](https://github.com/Level) and its activities, become a backer or sponsor on [Open Collective](https://opencollective.com/level). Your logo or avatar will be displayed on our 28+ [GitHub repositories](https://github.com/Level), [npm](https://www.npmjs.com/) packages and (soon) [our website](http://leveldb.org). 💖
137+
138+
### Backers
139+
140+
[![Open Collective backers](https://opencollective.com/level/backers.svg?width=890)](https://opencollective.com/level)
141+
142+
### Sponsors
143+
144+
[![Open Collective sponsors](https://opencollective.com/level/sponsors.svg?width=890)](https://opencollective.com/level)
145+
122146
## License
123147

124148
[MIT](LICENSE.md) © 2013-present Rod Vagg and [Contributors](CONTRIBUTORS.md).
149+
150+
[level-badge]: http://leveldb.org/img/badge.svg
151+
152+
[levelup]: https://github.com/Level/levelup
153+
154+
[level]: https://github.com/Level/level
155+
156+
[level-hyper]: https://github.com/Level/level-hyper

Diff for: package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
"scripts": {
1111
"test": "standard && hallmark && nyc node test.js",
1212
"coverage": "nyc report --reporter=text-lcov | coveralls",
13-
"hallmark": "hallmark --fix"
13+
"hallmark": "hallmark --fix",
14+
"dependency-check": "dependency-check . test.js",
15+
"prepublishOnly": "npm run dependency-check"
1416
},
1517
"dependencies": {
1618
"after": "~0.8.2",
@@ -20,6 +22,7 @@
2022
"devDependencies": {
2123
"bytewise": ">=0.8",
2224
"coveralls": "^3.0.2",
25+
"dependency-check": "^3.3.0",
2326
"hallmark": "^0.1.0",
2427
"level-community": "^3.0.0",
2528
"level-concat-iterator": "^2.0.0",

0 commit comments

Comments
 (0)