I want to store an array of objects in redis
const items = [
{
'122': {
name: 'abc',
price: '12',
},
},
{
'1225656': {
name: 'bc',
price: '35',
},
},
];
I want to store an array of objects in redis
const items = [
{
'122': {
name: 'abc',
price: '12',
},
},
{
'1225656': {
name: 'bc',
price: '35',
},
},
];
if you were to use string data type, this is how you do it
// set it
await redis.set('keyname', JSON.stringify(items))
// get it back
const dataStr = await redis.get('keyname')
const data = JSON.parse(dataStr)
of course you can use other data type like hash (or storing list items) and list (item keys) all together. but if the json payload is small, I think you will be just fine using string.