Back to Browse

Increment Redis Counter in Edge Functions

3.6K views
Mar 7, 2023
10:35

Redis[0] is an open source (BSD licensed), in-memory data structure store used as a database, cache, message broker, and streaming engine. It is optimised for atomic operations like incrementing a value, for example for a view counter or rate limiting. Upstash[1] provides an HTTP/REST based Redis client which is ideal for serverless use-cases and therefore works well with Supabase Edge Functions[2]. Find the code: https://github.com/thorwebdev/edgy-edge-functions/blob/main/supabase/functions/upstash-redis-counter/index.ts 🎙️ Presented by Thor Schaeff (@thorwebdev https://go.thor.bio/x) ## Chapters 00:00 Intro to Redis 00:46 Redis Counter Example 01:20 Create a new Supabase Function 01:46 Create a Redis Database on Upstash 02:26 Set up Redis Upstash REST API env variables 03:15 Create the Redis Counter 04:35 Initialize Redis Client in Deno 05:00 Using Redis Hash Increment 06:30 Serve the function locally 08:40 Deploy Redis Counter to the Edge ## About Edgy Edge Functions Edgy Edge Functions is a video series where we explore Supabase Edge Functions[2] and Deno[3] functionality and features. If there's something you'd like to learn about, please open an issue[4] and let me know on this Tweet thread[5]. Thanks for stopping by! Denosaur and I will see you soon \o/ [0] https://redis.io/docs/about/ [1] https://upstash.com/ [2] https://supabase.com/edge-functions [3] https://deno.land/ [4] https://github.com/thorwebdev/edgy-edge-functions/issues/new/choose [5] https://twitter.com/thorwebdev/status/1595719098863788032

Download

0 formats

No download links available.

Increment Redis Counter in Edge Functions | NatokHD