Skip to content

Commit 4c0a941

Browse files
authored
IS-3066: Bytter til Valkey (#1636)
1 parent 520e9b0 commit 4c0a941

File tree

5 files changed

+21
-18
lines changed

5 files changed

+21
-18
lines changed

.nais/naiserator-dev.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ spec:
4747
claims:
4848
extra:
4949
- "NAVident"
50-
redis:
50+
valkey:
5151
- instance: cache
5252
access: readwrite
5353
accessPolicy:

.nais/naiserator-prod.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ spec:
4747
claims:
4848
extra:
4949
- "NAVident"
50-
redis:
50+
valkey:
5151
- instance: cache
5252
access: readwrite
5353
accessPolicy:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ $ cp .env.template .env # for å sette opp lokale miljøvariabler
2929
$ npm install # installerer avhengigheter
3030
```
3131

32-
## Redis Cache
32+
## Valkey Cache
3333

34-
Bruker teamsykefravr sin felles Redis-cache på Aiven for å cache bruker-sessions.
34+
Bruker teamsykefravr sin felles Valkey-cache på Aiven for å cache bruker-sessions.
3535

3636
## Event tracking
3737

server/config.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,13 @@ export const auth = {
411411
},
412412
};
413413

414-
export const redis = {
415-
uri: envVar({ name: "REDIS_URI_CACHE", defaultValue: "" }),
416-
username: envVar({ name: "REDIS_USERNAME_CACHE", defaultValue: "" }),
417-
password: envVar({ name: "REDIS_PASSWORD_CACHE", defaultValue: "" }),
414+
export const valkey = {
415+
uri: envVar({ name: "VALKEY_URI_CACHE", defaultValue: "" }).replace(
416+
"valkeys",
417+
"rediss"
418+
),
419+
username: envVar({ name: "VALKEY_USERNAME_CACHE", defaultValue: "" }),
420+
password: envVar({ name: "VALKEY_PASSWORD_CACHE", defaultValue: "" }),
418421
database: 18,
419422
};
420423

@@ -427,7 +430,7 @@ module.exports = {
427430
auth: auth,
428431
isDev: isDev,
429432
isProd: isProd,
430-
redis: redis,
433+
valkey: valkey,
431434
unleash: unleash,
432435
server: server,
433436
};

server/session.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ const SESSION_MAX_AGE_MILLIS = 12 * 60 * 60 * 1000;
99

1010
const SESSION_MAX_AGE_SECONDS = SESSION_MAX_AGE_MILLIS / 1000;
1111

12-
const getRedisClient = () => {
13-
const redisClient = redis.createClient({
14-
url: Config.redis.uri,
12+
const getValkeyClient = () => {
13+
const valkeyClient = redis.createClient({
14+
url: Config.valkey.uri,
1515
no_ready_check: true,
1616
});
17-
redisClient.auth(Config.redis.password, Config.redis.username);
18-
redisClient.select(Config.redis.database);
19-
return redisClient;
17+
valkeyClient.auth(Config.valkey.password, Config.valkey.username);
18+
valkeyClient.select(Config.valkey.database);
19+
return valkeyClient;
2020
};
2121

22-
const getRedisStore = () => {
22+
const getValkeyStore = () => {
2323
if (Config.isDev) return undefined;
2424
const RedisStore = connectRedis(session);
2525
return new RedisStore({
26-
client: getRedisClient(),
26+
client: getValkeyClient(),
2727
ttl: SESSION_MAX_AGE_SECONDS,
2828
disableTouch: true,
2929
});
@@ -45,7 +45,7 @@ export const setupSession = (app: express.Application) => {
4545
resave: true,
4646
saveUninitialized: false,
4747
unset: "destroy",
48-
store: getRedisStore(),
48+
store: getValkeyStore(),
4949
rolling: true,
5050
})
5151
);

0 commit comments

Comments
 (0)