UNPKG

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) 747 B
export default async e=>{const{socket:t,payload:a}=e;try{const s=t.p3xrs.ioredis,{key:o,type:r,item:c,quantile:l}=a;let i;switch(console.info("socket.io probabilistic check",r,o,c||l),r){case"bloom":i=await s.call("BF.EXISTS",o,c);break;case"cuckoo":i=await s.call("CF.EXISTS",o,c);break;case"topk":{const e=await s.call("TOPK.LIST",o,"WITHCOUNT"),t=[];for(let a=0;a<e.length;a+=2)t.push({item:e[a],count:parseInt(e[a+1])||0});i=t;break}case"cms":i=await s.call("CMS.QUERY",o,c);break;case"tdigest":i=await s.call("TDIGEST.QUANTILE",o,parseFloat(l));break;default:throw new Error("unsupported-probabilistic-type")}t.emit(e.responseEvent,{status:"ok",result:i})}catch(a){console.error(a),t.emit(e.responseEvent,{status:"error",error:a.message})}};