Currently, used_requests is stored in Redis with an expiration matching the user's subscription period_end. However, this approach lacks a method for tracking historical data unless we implemented heartbeats, which would be inefficient.
The proposed solution is to store the user's period_end in Redis. When this timestamp is <= now(), a historical entry should be added to a stats table in Supabase. Following this, the used_requests key in Redis would be reset to zero.
Currently,
used_requests
is stored in Redis with an expiration matching the user's subscriptionperiod_end
. However, this approach lacks a method for tracking historical data unless we implemented heartbeats, which would be inefficient.The proposed solution is to store the user's
period_end
in Redis. When this timestamp is<= now()
, a historical entry should be added to a stats table in Supabase. Following this, theused_requests
key in Redis would be reset to zero.