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) 776 B
import*as e from"../../shared.mjs";const t="socket.io delete search keys";export default async s=>{const{socket:o,payload:n}=s;try{e.ensureReadonlyConnection({socket:o});let a=o.p3xrs.ioredis;if(console.info(t,n.match),n.match&&"*"!==n.match){const r=await e.getStreamKeys({redis:a,match:n.match,maxKeys:n.maxKeys});if(0===r.length)return void o.emit(s.responseEvent,{status:"ok",deletedCount:0});const i=a.pipeline();for(let e of r)console.info(t,"delete key",e),i.del(e);await i.exec(),o.emit(s.responseEvent,{status:"ok",deletedCount:r.length})}else{const e=await a.dbsize();console.info(t,"flushdb, dbsize was",e),await a.flushdb(),o.emit(s.responseEvent,{status:"ok",deletedCount:e})}}catch(e){console.error(e),o.emit(s.responseEvent,{status:"error",error:e.message})}};