Skip to content

Commit

Permalink
🗃️ Split erpc memory storage for realtime + unfinalized
Browse files Browse the repository at this point in the history
  • Loading branch information
KONFeature committed Dec 19, 2024
1 parent 15b5e24 commit 6e907c5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/erpc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN cd /tmp/dev && bun build --outfile ./erpc.js --minify --target node --extern

# Final image
#FROM erpc-dev AS final
FROM ghcr.io/erpc/erpc@sha256:c62bd25d011cb0cf354689685edcf81ef49480c532d7b980a1f4cf0be3bdd0ea AS final
FROM ghcr.io/erpc/erpc@sha256:c2e09378e5b7922428e8363c577fdf063aaf3d060e79ce44f8f9006c47bc80f6 AS final

# Install curl, will be used for healthcheck
RUN apt-get update && apt-get install -y curl
Expand Down
20 changes: 15 additions & 5 deletions packages/erpc/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,19 @@ const connectors = [
},
},
{
id: "memory-main",
id: "memory-unfinalized",
driver: "memory",
memory: {
maxItems: 65_536,
// max 4k items for unfinalized cache
maxItems: 4_096,
},
},
{
id: "memory-realtime",
driver: "memory",
memory: {
// Max 4k items for realtime cache
maxItems: 4_096,
},
},
] as const satisfies ConnectorConfig[];
Expand All @@ -50,17 +59,18 @@ const cachePolicies = [
},
// Cache not finalized data for 2sec in the memory
{
connector: "memory-main",
connector: "memory-unfinalized",
network: "*",
method: "*",
finality: DataFinalityStateUnfinalized,
empty: CacheEmptyBehaviorIgnore,
// 2sec in nanoseconds
ttl: 2_000_000_000,
maxItemSize: "20kb",
},
// Cache realtime data for 2sec on the memory on arbitrum
{
connector: "memory-main",
connector: "memory-realtime",
network: "evm:42161",
method: "*",
finality: DataFinalityStateRealtime,
Expand All @@ -70,7 +80,7 @@ const cachePolicies = [
},
// Cache realtime data for 30sec on arbitrum sepolia
{
connector: "memory-main",
connector: "memory-realtime",
network: "evm:421614",
method: "*",
finality: DataFinalityStateRealtime,
Expand Down

0 comments on commit 6e907c5

Please sign in to comment.