Skip to content

Commit

Permalink
test: uses teststring to set into redis cache at session start
Browse files Browse the repository at this point in the history
  • Loading branch information
arnoldknott committed Jan 11, 2024
1 parent e7d24ff commit 5eeb6f7
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions frontend_svelte/src/lib/server/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,23 @@ export const setSession = async (sessionId: string, path: string, sessionData: S
console.log("🥞 cache - server - setSession - sessionData.account.localAccountId");
console.log(sessionData.account.localAccountId);
const authDataString = JSON.stringify(sessionData);
console.log("🥞 cache - server - setSession - authDataString");
console.log(authDataString);
try{
console.log("🥞 cache - server - setSession");
if (!redisClient){
throw new Error("🥞 cache - server - setSession - redisClient not initialized");
}
// const statusPromise = redisClient.json.set(sessionId, path, authDataString);
// TBD: move back to json.set when the redis client is fixed?
const statusPromise = redisClient.set(sessionId, authDataString);
statusPromise?.catch((err) => {
console.error("🥞 cache - server - setSession - redisClient?.json.set failed");
console.error(err);
// throw err
})
const setStatus = await statusPromise;
console.log("🥞 cache - server - setSession - path");
console.log(path);
const setStatus = await redisClient?.json.set(sessionId, ".", "teststring");
// const setStatus = await redisClient.json.set(sessionId, path, authDataString);
// statusPromise?.catch((err) => {
// console.error("🥞 cache - server - setSession - redisClient?.json.set failed");
// console.error(err);
// // throw err
// })
// const setStatus = await statusPromise;
console.log("🥞 cache - server - setSession - sessionId set");
await redisClient?.expire(sessionId, sessionTimeOut)
console.log("🥞 cache - server - setSession - sessionId expired");
Expand Down Expand Up @@ -138,9 +141,7 @@ export const setSession = async (sessionId: string, path: string, sessionData: S
throw new Error('Session ID is null');
}
try{
// TBD: move back to json.get when the redis client is fixed?
// const result = await redisClient?.json.get(sessionId);
const result = await redisClient?.get(sessionId);
const result = await redisClient?.json.get(sessionId);
return result ? JSON.parse(result) as Session : undefined;
} catch (err) {
console.error("🥞 cache - server - getSession - redisClient?.json.get failed");
Expand Down

0 comments on commit 5eeb6f7

Please sign in to comment.