
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
@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
redlock
is 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";
},
},
},
});
3.0.2
FAQs
Heavily inspired by @envelop/response-cache
The npm package @soundxyz/response-cache receives a total of 80 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.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.