firebase-functions-rate-limiter
firebase-functions-rate-limiter copied to clipboard
Explicitly add field "expireAt" on the limiter entries in Firestore
Motivation / Context
I'm using the firebase-functions-rate-limiter
library, and I need the ability to automatically remove entries from Firestore that are no longer in use. Currently, the library does not provide a built-in mechanism to set an expireAt field for Firestore entries.
Description
I kindly request the addition of a feature that allows users to automatically create an expireAt
field for Firestore entries when configuring the rate limiter, based on the provided periodSeconds
value. This enhancement would simplify the management of rate limiter entries and enable automatic cleanup based on the defined expiration time.
Proposed Implementation:
When configuring the rate limiter, we are allowed to set a periodSeconds value, which defines the time span during which rate limiter entries are valid.
When a rate limiter entry is first created or checked, we need to automatically create an expireAt
field in Firestore, calculated as the current timestamp plus the specified periodSeconds
.
Additional context
Based on this field "expireAt", we can setup a TTL policy: https://firebase.google.com/docs/firestore/ttl
When you get the chance, please review this @Jblew @jondcallahan thank you
You can use the firebase schedule functions to periodically delete that data . Here is the link to the docs Schedule Functions . I hope this helps