-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: base caching #55
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, again weird paths xd but lgtm. caching is everywhere in our app ⚡
@@ -1,11 +1,11 @@ | |||
import { inspect } from "util"; | |||
import { caching } from "cache-manager"; | |||
|
|||
import { EvmProvider } from "@zkchainhub/chain-providers/dist/src/index.js"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { EvmProvider } from "@zkchainhub/chain-providers/dist/src/index.js"; | |
import { EvmProvider } from "@zkchainhub/chain-providers"; |
@@ -1,6 +1,7 @@ | |||
import { Address, encodeFunctionData, erc20Abi, parseEther, zeroAddress } from "viem"; | |||
import { afterEach, describe, expect, it, Mocked, vi } from "vitest"; | |||
|
|||
import { EvmProvider, MulticallNotFound } from "@zkchainhub/chain-providers/dist/src/index.js"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { EvmProvider, MulticallNotFound } from "@zkchainhub/chain-providers/dist/src/index.js"; | |
import { EvmProvider, MulticallNotFound } from "@zkchainhub/chain-providers"; |
import { NextFunction, Request, Response } from "express"; | ||
import NodeCache from "node-cache"; | ||
|
||
const DEFAULT_TTL = 60; // 1 minute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we add this as env config too? maybe add it to tech debt to not forget
|
||
res.json = (body): Response => { | ||
// Cache the response body | ||
cache.set(key, body, args.ttl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do NodeCache
instances have some kind of limit on how many items it can cache? I understand this is a v0.1 solution so no worries if you've taken into account this potentially growing a lot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is just a temporary solution, no idea how many items can NodeCache handle. In this case we are just gona have 2 items.
🤖 Linear
Closes ZKS-208 Closes ZKS-199
Description
ecosystem
andzkchain
endpointsWe decided to move forward with
NodeCache
sincecacheable
by nature uses Promises so hit the cache, this causes some problems when trying to overrideres.json
hook on express sinceres.json
is considered sync.For next steps we will:
cacheable
for modules advanced cachingcacheable
for the cacheMiddleware