I came across the new Redis-OM Node Object Mapping functionality, I’ve not really experimented with Redis before but I thought now might be the time to give it a go.
Right now I have a basic function set up for creating a room but I would like the room to expire after say 24 hours (86400 seconds iirc).
export async function createRoom(data) {
await connect();
const repository = new Repository(schema, client);
const room = repository.createEntity(data);
const id = await repository.save(room);
return id;
}
How do I set the TTL or expire time for an object using the Object Mapping approach… see my schema below.
class Room extends Entity {}
let schema = new Schema(
Room,
{
code: { type: 'string' },
playlist: { type: 'array', videos: { type: 'string' } },
},
{
dataStructure: 'JSON',
}
);