p3x-redis-ui-server
Version:
🏍️ P3X Redis UI server — Socket.IO backend for the dual Angular + React frontend with AI queries, 54 languages, and auto data decompression
2 lines (1 loc) • 618 B
JavaScript
export default async e=>{const{socket:t,payload:s}=e;try{const o=t.p3xrs.ioredis,{key:r,mode:a,element:l,values:n,count:c,filter:p}=s,u=parseInt(c)||10;let m;if("element"===a){const e=["VSIM",r,"ELE",l,"COUNT",u,"WITHSCORES"];p&&e.push("FILTER",p),m=await o.call(...e)}else{const e=["VSIM",r,"VALUES",n.length,...n.map(Number),"COUNT",u,"WITHSCORES"];p&&e.push("FILTER",p),m=await o.call(...e)}const E=[];for(let e=0;e<m.length;e+=2)E.push({element:m[e],score:parseFloat(m[e+1])||0});t.emit(e.responseEvent,{status:"ok",results:E})}catch(s){console.error(s),t.emit(e.responseEvent,{status:"error",error:s.message})}};