New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

keyv

Package Overview
Dependencies
Maintainers
2
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

keyv - npm Package Compare versions

Comparing version 5.2.1 to 5.2.2

16

dist/index.js

@@ -39,3 +39,3 @@ // src/index.ts

const index = listeners.indexOf(listener);
if (index > -1) {
if (index !== -1) {
listeners.splice(index, 1);

@@ -209,3 +209,5 @@ }

"mongo",
"redis"
"redis",
"valkey",
"etcd"
];

@@ -551,6 +553,12 @@ var Keyv = class extends event_manager_default {

const serializedValue = await this.serializeData(formattedValue);
await store.set(keyPrefixed, serializedValue, ttl);
let result = true;
try {
await store.set(keyPrefixed, serializedValue, ttl);
} catch (error) {
result = false;
this.emit("error", error);
}
this.hooks.trigger("postSet" /* POST_SET */, { key: keyPrefixed, value: serializedValue, ttl });
this.stats.set();
return true;
return result;
}

@@ -557,0 +565,0 @@ /**

{
"name": "keyv",
"version": "5.2.1",
"version": "5.2.2",
"description": "Simple key-value storage with support for multiple backends",

@@ -72,15 +72,15 @@ "type": "module",

"dependencies": {
"@keyv/serialize": "*"
"@keyv/serialize": "^1.0.1"
},
"devDependencies": {
"@keyv/compress-brotli": "*",
"@keyv/compress-gzip": "*",
"@keyv/memcache": "*",
"@keyv/mongo": "*",
"@keyv/sqlite": "*",
"@keyv/test-suite": "*",
"rimraf": "^6.0.1",
"timekeeper": "^2.3.1",
"tsd": "^0.31.2",
"xo": "^0.59.3"
"xo": "^0.60.0",
"@keyv/mongo": "^3.0.1",
"@keyv/compress-gzip": "^2.0.2",
"@keyv/test-suite": "^2.0.3",
"@keyv/sqlite": "^4.0.1",
"@keyv/memcache": "^2.0.1",
"@keyv/compress-brotli": "^2.0.2"
},

@@ -87,0 +87,0 @@ "tsd": {

@@ -280,38 +280,4 @@ <h1 align="center"><img width="250" src="https://jaredwray.com/images/keyv.svg" alt="keyv"></h1>

- [keyv-momento](https://github.com/momentohq/node-keyv-adaptor/) - Momento storage adapter for Keyv
- [@resolid/keyv-sqlite](https://github.com/huijiewei/keyv-sqlite) - A new SQLite storage adapter for Keyv
# Add Cache Support to your Module
Keyv is designed to be easily embedded into other modules to add cache support. The recommended pattern is to expose a `cache` option in your modules options which is passed through to Keyv. Caching will work in memory by default and users have the option to also install a Keyv storage adapter and pass in a connection string, or any other storage that implements the `Map` API.
You should also set a namespace for your module so you can safely call `.clear()` without clearing unrelated app data.
Inside your module:
```js
class AwesomeModule {
constructor(opts) {
this.cache = new Keyv({
uri: typeof opts.cache === 'string' && opts.cache,
store: typeof opts.cache !== 'string' && opts.cache,
namespace: 'awesome-module'
});
}
}
```
Now it can be consumed like this:
```js
import AwesomeModule from 'awesome-module';
// Caches stuff in memory by default
const awesomeModule = new AwesomeModule();
// After npm install --save keyv-redis
const awesomeModule = new AwesomeModule({ cache: 'redis://localhost' });
// Some third-party module that implements the Map API
const awesomeModule = new AwesomeModule({ cache: some3rdPartyStore });
```
# Compression

@@ -318,0 +284,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc