
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
@soundxyz/response-cache
Advanced tools
Alternative to @envelop/response-cache with new features:
ttlPerSchemaCoordinate.get calls (Multiple concurrent calls to redis re-use the same promise)pnpm add @soundxyz/response-cache
yarn add @soundxyz/response-cache
npm install @soundxyz/response-cache
redlockis optional
pnpm add ioredis redlock
yarn add ioredis redlock
npm install ioredis redlock
Most of the configuration is the same as with @envelop/response-cache
import Redis from "ioredis";
import RedLock from "redlock";
export const redis = new Redis();
export const redLock = new RedLock([redis], {});
import {
createRedisCache,
useResponseCache,
UseResponseCacheParameter,
} from "@soundxyz/response-cache";
import ms from "ms";
import { redis, redLock } from "./redis";
export const responseCache = createRedisCache({
// ioredis instance
redis,
// Don't specify or set to `null` to disable
redlock: {
// Client created calling the `redlock` package
client: redLock,
// The default is 5000ms
duration: 5000,
settings: {
// The default is ((duration / retryDelay) * 2)
retryCount: (5000 / 250) * 2,
// The default is 250ms
retryDelay: 250,
},
},
});
const cacheConfig: UseResponseCacheParameter = {
cache: responseCache,
// cache operations for 1 hour by default
ttl: ms("1 hour"),
ttlPerSchemaCoordinate: {
"Query.fooBar": 0,
},
includeExtensionMetadata: true,
};
// ...
({
plugins: [
//...
useResponseCache(cacheConfig),
],
});
We have to add the ResponseCache context type in your custom context:
import type { ResponseCacheContext } from "@soundxyz/response-cache";
export interface Context extends ResponseCacheContext {
// ...
}
Then you can use it directly on your resolvers:
// ...
makeExecutableSchema({
typeDefs: `
type Query {
hello: String!
}
`,
resolvers: {
Query: {
hello(_root, _args, context: Context) {
// Get the current expiry to be used for the cache TTL
const expiry = ctx.$responseCache?.getExpiry();
// You can use any logic
if (expiry != null && expiry > 500) {
// Set the expiry to any arbitrary value in milliseconds
context.$responseCache?.setExpiry({
// TTL in ms
ttl: 1000,
});
}
return "Hello World";
},
},
},
});
FAQs
Heavily inspired by @envelop/response-cache
The npm package @soundxyz/response-cache receives a total of 270 weekly downloads. As such, @soundxyz/response-cache popularity was classified as not popular.
We found that @soundxyz/response-cache demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 13 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.