You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because ioredis is also another popular Redis client library
Here is my example code like the code in with-redis
import{Server}from"https://deno.land/[email protected]/http/server.ts";importIORedisfrom'npm:[email protected]'// make a connection to the local instance of redisconstclient=newIORedis("redis://localhost:6379")client.on("error",(error)=>{console.error(error);});constserver=newServer({handler: async(req)=>{const{ pathname }=newURL(req.url);// strip the leading slashconstusername=pathname.substring(1);constcached_user=awaitclient.get(username);if(cached_user){returnnewResponse(cached_user,{headers: {"content-type": "application/json","is-cached": "true",},});}else{constresp=awaitfetch(`https://api.github.com/users/${username}`);constuser=awaitresp.json();awaitclient.set(username,JSON.stringify(user));returnnewResponse(JSON.stringify(user),{headers: {"content-type": "application/json","is-cached": "false",},});}},port: 3000,});server.listenAndServe();
The text was updated successfully, but these errors were encountered:
Because
ioredis
is also another popular Redis client libraryHere is my example code like the code in
with-redis
The text was updated successfully, but these errors were encountered: