-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add increment option. #12
Comments
Thanks for the idea but yeah, that's definitely out of scope. I really wanna keep this simple and focused on key-value API compatibility across backends. The only features I'd probably consider adding are other API methods from |
I also need this functionality (actually for a similar reason) and wanted to confirm it's out of scope before I go write my own package to do this. Unfortunately you can't just build this functionality on top of keyv because you need to talk to the stores in a different way for this to be an atomic operation (where you don't get lost updates with concurrent requests and separate That said, all the stores I know about that you support are either synchronous (e.g. Map(), quick-lru) or support an atomic increment mechanism (memcached, redis, mongo, sql, dynamodb) - so it's technically possible but does extend outside of the Map API spec. |
Yeah I think so, but thanks for checking back.
Why not fork Keyv? If the changes are relatively simple and it works well across all storage adapters, I might be open to merging it in. If it's too complex or doesn't work reliably enough across storage adapters, you'll still have your own fully working package for your own needs. |
* Initial commit * docs(readme): add Greenkeeper badge * Setup entry schema * Use key as primary key * Ensure keys are unique and indexable * Disable timestamps * Add get/set/delete methods * Add clear method * Wait for connection before running queries * Return Boolean for delete method * clear method always resolves to undefined * get method returns undefined on nonexistent keys * Disable logging by default * 0.1.0 * Make invalid connection string more clear * Explicitly use memory for tests * KeyvSQLite => KeyvSqlite * Respect table name * Don't run tests in memory * Accept connection string as contructor argument * Make sure clear only clears current namespace * 0.2.0 * Remove Greenkeeper badge * Test options have expected defaults * Extract keyv-sequelize from keyv-sqlite * Update metadata/readme for Sequelize * Test against SQLite * Set defaults for logging/table * 0.1.0 * Test connection errors are emitted * Extract keyv-sql from keyv-sequelize * Add set method * Add get method * Add delete method * Add clear method * 0.1.0 * Test against SQLite * Ensure keys are unique and indexed as primary keys * Make sure set can update or insert * Use our fork of sql until REPLACE support is merged brianc/node-sql#368 * Keep XO happy * Move back to sql Our changes were merged 🎉 * 0.2.0 * Refactor query into method * Use large busyTimeout with tests Stops 'SQLITE_BUSY: database is locked' errors from creating loads of connections * 0.2.1 * Wrap upserts in if/else so we only run the correct functions Otherwise node-sql will throw errors when building a query that Postgres can't handle * 0.2.2 * Expose opts.dialect rather than sql.dialectName * 0.2.3 * Update to requirable * Lock dependency versions * 0.2.4 * List keyv-postgres and keyv-mysql * 1.0.0 * Fix old Sequelize wording * 1.0.1 * Add keyv logo to header * 1.0.2 * Update sql to the latest version 🚀 (#3) * 1.0.3 * Scope to @keyv * 1.0.4 * Update readme for new scope * 1.0.5 * Update ava to the latest version 🚀 (#7) * Fix JSON quotes in MySQL * 1.0.6 * Allow setting custom VARCHAR key size * Ensure opts.keySize is a number * Test keySize option * 1.1.0 * Add .npmignore * 1.1.1 * Fix bad URLs in package.json (sqlite -> sql) (#10) * 1.1.2 * Update coveralls to the latest version 🚀 (#11) * Update ava to the latest version 🚀 (#12) * Update ava to the latest version 🚀 (#13) * Update ava to the latest version 🚀 (#14) * Update sqlite3 to the latest version 🚀 (#16) * upgrading sqlite3 to version 5.0.2 * creating build yaml for github actions * removing travis ci from build process * updating workflows naming * upgrading pify to version 5.0.0 * updating license to include authors * updating with build status badge * upgrading xo to version 0.45.0 * fixing standard xo issues * fixing standard xo issues * upgrading nyc to version 15.1.0 * upgrading ava to version 3.15.0 * version bump to 1.1.3 * updating authors and github links to jaredwray * updating to include coverage for sql * adding in clean variables and removing rimraf * removing rimraf * removing sqlite * removing sqlite file * moving sql to mono * adding in clean up of sqlite test db * removing from main keyv since importing to mono * validating value coming back Co-authored-by: Luke Childs <lukechilds123@gmail.com> Co-authored-by: greenkeeper[bot] <greenkeeper[bot]@users.noreply.github.com> Co-authored-by: MySidesTheyAreGone <mysidestheyaregone@protonmail.com>
* Initial commit * 0.1.0 * Exclude src from npm and dist from git * 0.1.1 * Make sure we always transpile for Node.js 4 The AVA preset only targets the Node.js version used to build. * 0.1.2 * Add usage example to readme * Mention keyv-redis as existing example * 1.0.0 * Tweak wording * `keyv` => Keyv * Capitalise title * 1.0.1 * Link to AVA/Keyv * Fix markdown heading * 1.0.2 * Update dependencies to enable Greenkeeper 🌴 (#1) * chore(package): update dependencies * Readme wording * Clear store before each test and cleanup afterwards * Test .clear() deletes all key/value pairs * Test .clear() resolves to undefiend * Test .clear() returns a Promise * Move tests around * Test .set(key, value) sets a value * Test .delete(key) deletes a key * 1.1.0 * Fix lint error * Add bigger delay to wait for TTL to expire This was sometimes failing on Node.js 4 * 1.1.1 * chore(package): update ava to version 0.21.0 (#2) * Test value can be an object * Test value can be a buffer * Test value can be an object containing a buffer * Test value can be null * Test value can be undefined * Test value can be a number * .set should now resolve to true * 1.2.0 * Rename to keyv-test-suite * Split tests up into seperate files Allow tests to be imported seperately or use helper to run them all * Add official tests * 1.3.0 * Use get-root-module * Test keyvOfficialTests against keyv-redis * Run Redis on Travis * Test namespaced .set(key, value) don't collide * Rename test to make it clear we're testing both set and get * Test namespaced delete only deletes from current namespace * Test namespaced clear only clears current namespace * Use new store instace for each test * Fix typo * 1.4.0 * docs(readme): add Greenkeeper badge (#3) * Remove Greenkeeper badge * Use this (renamed get-root-module) * 1.4.1 * Increase TTL delay to stop false positives * 1.4.2 * Spoof date if possible * Test against SQLite not Redis * Update docs * Update keywords * 1.5.0 * Scope to @keyv * 1.5.1 * Fix timings so tests don't fail for slow writes * 1.5.2 * Update ava to the latest version 🚀 (#9) * Test value can contain quotes * 1.6.0 * Add .npmignore * 1.6.1 * Remove .npmignore * 1.6.2 * 1.6.3 * Add .npmignore * 1.6.4 * Update timekeeper to the latest version 🚀 (#10) * 1.6.5 * pkg.files over .npmignore * 1.6.6 * Revert "pkg.files over .npmignore" This reverts commit 045b652acc6ace1d63bc81aaf6aeeda5577e790f. * 1.6.7 * Add everything to .npmignore apart from dist * 1.6.8 * Revert "Add everything to .npmignore apart from dist" This reverts commit 4495a78b139eb00b062967c43060b7934b8630f0. * 1.6.9 * Add everything to .npmignore apart from dist * 1.6.10 * Update coveralls to the latest version 🚀 (#11) * Update ava to the latest version 🚀 (#12) * Update ava to the latest version 🚀 (#13) * Update ava to the latest version 🚀 (#14) * await `keyv.clear()` before finishing test (#17) * 1.6.11 * compliancy -> compliance (#22) * handling yarn.lock * updating author * updating author * updating author * adding in build for node 12, 14, and 16 * Delete .travis.yml * adding in status badge * adding in the build script * remving the coverage file * updating coverage script * updating badge * upgrading nyc to version 15.1.0 * upgrading delay to version 2.0.0 * upgrading ava to version 3.15.0 * adding nvm to project for node 16 * upgrading xo to version 0.46.4 * spacing added * adding in file names * using require for buffer * version bump 1.6.12 * adding in dist to ignore * moving test-suite to mono repo Co-authored-by: Luke Childs <lukechilds123@gmail.com> Co-authored-by: greenkeeper[bot] <greenkeeper[bot]@users.noreply.github.com> Co-authored-by: Roney Rao <roneyrao@hotmail.com> Co-authored-by: Dan Dascalescu <ddascalescu+github@gmail.com>
* Initial commit * docs(readme): add Greenkeeper badge * Create Travis DB for tests * Use pq@6 pq@7 appears to have issues with Sequelize * 0.1.0 * Keyvpostgres => KeyvPostgres * Remove Greenkeeper badge * Use keyv-sql instead of keyv-sequelize * Format pq query results as array of rows for keyv-sql * Don't use obj destructuring for Node.js 4 compat * Remove sequelize dependencies * Update to keyv-sql 0.2.3 for latest Postgres compat * Test against Postgres 9.5 on Travis * Lock dependency versions * Only accept opts object as constructor argument * 1.0.0 * requireable => requirable * 1.0.1 * fix(package): update keyv-sql to version 0.2.4 (#4) * 1.0.2 * Finish docs * Update keyv-sql to the latest version 🚀 (#5) * 1.0.3 * fix(package): update keyv-sql to version 1.0.2 (#6) Closes #5 * 1.0.4 * Update pg to the latest version 🚀 (#7) * 1.0.5 * Update keyv-sql to the latest version 🚀 (#8) * 1.0.6 * Scope to @keyv * 1.0.7 * Import scoped test suite * 1.0.8 * Update pg to the latest version 🚀 (#11) * 1.0.9 * Update pg to the latest version 🚀 (#12) * 1.0.10 * Update ava to the latest version 🚀 (#13) * fix(package): update @keyv/sql to version 1.0.6 (#14) * fix(package): update pg to version 7.2.0 (#15) * 1.0.11 * Update pg to the latest version 🚀 (#17) * 1.0.12 * Update @keyv/sql to the latest version 🚀 (#18) * Update @keyv/sql to the latest version 🚀 (#19) * 1.0.13 * fix(package): update @keyv/sql to version 1.1.2 (#20) * 1.0.14 * Update coveralls to the latest version 🚀 (#21) * Update ava to the latest version 🚀 (#22) * Update pg to the latest version 🚀 (#23) * 1.0.15 * Update ava to the latest version 🚀 (#24) * Update pg to the latest version 🚀 (#25) * 1.0.16 * Update package.json Old versions of pg don't work with new versions of node.js (14+) * moving github actions to build * moving to local postgres * updating to create the database * creating database * set the user password * updating command formatting * updating postgres password * same user and pass * user and pass the same * updating to handle xo upgrade * updating to handle new format with xo * upgrading nyc to latest version 15.1.0 * removing travis ci as no longer needed * updated build status badge on readme * upgrade xo to version 0.45.0 * fix options to be named correctly * upgrading ava to version 3.15.0 * moving testing to staged * fixing tests * updating to just Official Tests * Update test.js * adding in api tests * adding in value tests * moving build to 1 parallel process * update to stop and start the service * trying createdb * trying create db * adding in owner * adding in multiple stores * version bump for release v1.0.17 * updated for serial flag on ava * updated tests to more uniform * adding in docker compose for testing * adding in docker compose for build * adding in docker compose via scripts * updating to use npm run * moving to latest version of postgres * correcting flow of build * moved docker compose to test folder * changed naming convention to be more uniform * updating for new npm run command to start postgres * updated compose to test folder and removed values * updated readme around how to test * naming adjusted * updating for testing * Update README.md * updating licensing for all authors * adding nvm and also removing yarn to standardize on npm * upgrading xo to version 0.46.4 * updating build to reference correct testing * upgrading @keyv/sql to version 1.1.3 * adding codecov on build workflow * removing codecoverage output from project * remving coveralls * updating badge * updating to run coverage * version bump to v1.0.18 * no longer needed * import @keyv/postgres to mono repo Co-authored-by: Luke Childs <lukechilds123@gmail.com> Co-authored-by: greenkeeper[bot] <greenkeeper[bot]@users.noreply.github.com> Co-authored-by: Andrey Frimuchkov <afrimuchkov@yandex.ru>
* Initial commit * Connect to MongoDB on init * Use mongojs driver instead of mongodb * Add set method * Add get method * Add missing semi * Add delete method * Protect user from accidentally clearing collection * Add clear method * Fix lint error * Make sure nonexistent keys are handled * Expose options object * Test Redis URL can be passed in as string * Test collection option merges into default options * Test .delete() with no args doesn't empty the collection * 0.1.0 * Create unique index for keys * Create TTL index to clear old keys * 0.2.0 * Ad usage example to readme * Don't rely on expirey date from Keyv, calculate our own * Make sure opts.uri from keyv is mapped to opts.url for mongojs * 0.2.1 * Emit connection errors on keyv * 0.3.0 * Emit error events * Update to keyv-api-suite * Setup requirable * Add support for clearing namespaced collections * 0.4.0 * Remove unused dev dep * Update requireable to ^1.0.1 * Update dependencies to enable Greenkeeper 🌴 (#1) * chore(package): update dependencies * docs(readme): add Greenkeeper badge * reorder * Remove Greenkeeper badge * Use "this" * Update to requirable * Pin dependency versions * 1.0.0 * Finish docs * 1.0.1 * Update mongojs to the latest version 🚀 (#2) * 1.0.2 * Scope to @keyv * 1.0.3 * Update ava to the latest version 🚀 (#5) * Fix readme error * 1.0.4 * Update coveralls to the latest version 🚀 (#8) * Update ava to the latest version 🚀 (#9) * Update ava to the latest version 🚀 (#11) * Update mongojs to the latest version 🚀 (#13) * chore(package): update ava to version 0.25.0 (#12) * chore(package): update xo to version 0.20.1 (#15) Closes #14 * Drop tests for Node.js 4 and add tests for Node.js 10 (#26) Was failing anyway, and Node 4 was end-of-life'd in April. Add instead tests for Node 10 and current. * Support passing both URL and collection name to constructor (#25) * Support passing both URL and collection name to constructor * Add .env support * Revert "Support passing both URL and collection name to constructor" (#27) Reverts lukechilds/keyv-mongo#25 * Revert "Revert "Support passing both URL and collection name to constructor (#25)"" And fix version number change This reverts commit 8f06df9bf96f9201f0cbbbf5825a5778f46da780. * 1.1.0 * Updating mongojs and pify versions * Corrected set to use new syntax * Incremented minor version * adding support for default options * Create build.yaml * updating for the correct format * updating readme to new build status * removing travis ci as no longer needed * thanks @sittingbool for upgrading pify to version 5.0.0 * removing dotenv as it is not needed * upgrading xo to version 0.45.0 * upgrading nyc to version 15.1.0 * refactoring to a standard way of handling official tests * updating time and authors * updating authors * updating authors in readme * removing yarn.lock from repository * updating github location in package * updating readme to handle logo * adding in testing docker compose system * upgrading keyv to version 4.0.4 * upgrading @keyv/test-suite to version 1.6.12 * upgrading xo to version 0.46.4 * upgrading ava to version 3.15.0 * adding in testing coverage on url and uri * version bump to 1.2.1 * renaming to just mongo * removing the docker compose * removing licensing * updating to remove coveralls and add in correct coverage * updating to do code coverage for mongo Co-authored-by: Luke Childs <lukechilds123@gmail.com> Co-authored-by: greenkeeper[bot] <greenkeeper[bot]@users.noreply.github.com> Co-authored-by: Dan Dascalescu <ddascalescu+github@gmail.com> Co-authored-by: Damir Dado Mitrovic <damir@mitrovic.com.au>
Both mongodb and redis support a way increment variables directly. It would be nice to have something similar here. Specifically I am wanting to use keyv to implement a rate limiter but without increment it's impossible to do so.
May be out of scope for the module but I thought it'd be cool.
Also this module is legit. Thanks for making it :).
The text was updated successfully, but these errors were encountered: