The situation might be a bit complex, let's say I have a shopping cart related to items (items has some other relations with other entities) in a relational DB, it does not have any problem of query the shopping cart with all the other related entities by specifying them.
Now I am trying to move the shopping cart to Redis for high performance, if the shopping cart is created, with the items and the other relations will be saved to Redis.
await client.hSet(`shopping-cart:id:${cartId}`, {shoppingCartObj});
shoppingCartObj:
{
cartId: string,
items: [
item1: {
maker:{},
},
item2: {
maker:{},
},
item3: {
maker:{},
},
]
}
My question is the items and the items other related entities are still in DBMS like Postgres. They are still editable for users, like the maker. If the shopping cart is read from Redis always, they are out dated. Any strategy to maintain?
I can think of only maintain the shopping cart and the item relation in Redis with id links like cartId with itemId, if needed query again with the itemId.
Or load the items in the Redis as a copy, but will need to update if the user edited it.
Any other suggestions?