Skip to content

Commit

Permalink
hotfix: cache-config fix and remove logs
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipHarald committed Oct 8, 2024
1 parent 2952068 commit 89976a4
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 13 deletions.
2 changes: 1 addition & 1 deletion k8s/local/explorer-api/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ spec:
- name: POSTGRES_PASSWORD
value: "secret-local-password"
- name: CACHE_TTL
value: 2
value: "2"
readinessProbe:
httpGet:
path: /health
Expand Down
2 changes: 1 addition & 1 deletion k8s/production/aztec-listener/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ spec:
name: global
key: CHICMOZ_AZTEC_RPC
- name: AZTEC_GENESIS_CATCHUP
value: "false" # CHANGEME
value: "true"
- name: IGNORE_PROCESSED_HEIGHT
value: "false"
- name: AZTEC_LISTEN_FOR_BLOCKS
Expand Down
2 changes: 0 additions & 2 deletions k8s/production/explorer-api/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ spec:
value: "redis-master"
- name: REDIS_PORT
value: "6379"
- name: CACHE_TTL # CHANGEME
value: 2
readinessProbe:
httpGet:
path: /health
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,13 @@ import {
CACHE_LATEST_TTL_SECONDS,
CACHE_TTL_SECONDS,
} from "../../../../environment.js";
import { logger } from "../../../../logger.js";

const LATEST_HEIGHT = "latestHeight";

export const getLatestHeight = async () => {
const cachedVal = await c().get(LATEST_HEIGHT);
let dbVal = null;
if (cachedVal)
logger.info(`CACHE HIT: ${LATEST_HEIGHT} TTL: ${CACHE_LATEST_TTL_SECONDS}`);

if (!cachedVal) {
logger.info(
`CACHE MISS: ${LATEST_HEIGHT} TTL: ${CACHE_LATEST_TTL_SECONDS}`
);
// TODO: impl getLatestHeight in DB-controller
const block = await db.l2Block.getLatestBlock().catch(dbParseErrorCallback);
dbVal = block?.header.globalVariables.blockNumber ?? null;
Expand Down Expand Up @@ -50,9 +43,7 @@ export const get = async <DbReturnType>(
): Promise<string> => {
const cacheKey = keys.join("-");
let val = await c().get(cacheKey);
if (val) logger.info(`CACHE HIT: ${cacheKey} TTL: ${ttl}`);
if (!val) {
logger.info(`CACHE MISS: ${cacheKey} TTL: ${ttl}`);
const dbRes = await dbFn().catch(dbParseErrorCallback);
if (dbRes) {
val = JSON.stringify(dbRes);
Expand Down

0 comments on commit 89976a4

Please sign in to comment.