Complete the code to set a cache expiration time of 60 seconds.
const { data, error } = await supabase.from('items').select('*').cache({ ttl: [1] });Setting ttl to 60 means the cache will expire after 60 seconds.
Complete the code to enable cache for the query.
const { data, error } = await supabase.from('users').select('*').[1]();noCache() disables caching.clearCache() removes cached data.The cache() method enables caching for the query.
Fix the error in the cache invalidation code.
await supabase.cache.[1]('users');
clearCache is not a valid method.refreshCache does not exist in Supabase.The correct method to invalidate cache for a table is invalidateCache.
Fill both blanks to create a cache with a 5-minute expiration and force refresh.
const { data, error } = await supabase.from('products').select('*').cache({ ttl: [1], forceRefresh: [2] });TTL of 300 seconds equals 5 minutes. Setting forceRefresh to true forces fresh data.
Fill all three blanks to cache a query with a 10-minute TTL, disable force refresh, and specify a cache key.
const { data, error } = await supabase.from('orders').select('*').cache({ ttl: [1], forceRefresh: [2], key: '[3]' });TTL 600 seconds equals 10 minutes. forceRefresh false disables forced reload. The cache key is a string identifier.
