Reputation: 854
I have an application where users keep writing data to the database that only needs to last for 1 minute. For example, Alice stores {foo: bar}
at 10:36:00pm, and at 10:37:00pm, that entry should automatically be deleted from the database to free up memory, as it will never be used again.
Is there a way to do this, or do I have no choice but to manually have users delete their temp data after a minute? That wouldn't be ideal, because if a user "forgets" to (e.g. they lose their internet connection or close the app before they delete), then that entry will stay taking up space forever unless I set up a worker manually cleaning the database of these old entries.
For the record, the intended use case is to have Firestore act as a WebRTC signalling server, where users temporarily signal each other to establish a p2p connection.
Upvotes: 1
Views: 452
Reputation: 10732
As far as I can tell, there’s no such thing in Firestore. This mechanism is commonly described as TTL (Time To Live).
You can, however, roll your own TTL mechanism using Cloud Tasks.
For your use case, very “short-term”, heavy-rotation, ephemeral, and presumably small data, you may also consider Redis, which has built-in TTL and higher performance. Depending on your volume, may turn out cheaper as well.
Upvotes: 1