mirror of
https://github.com/labring/FastGPT.git
synced 2026-02-01 01:07:16 +08:00
perf: replace redis KEYS with SCAN (#6101)
* perf: replace redis KEYS with SCAN * test: add redis scan mock to fix unit tests * Fix formatting in redis.ts mock functions * fix comment word Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -17,6 +17,7 @@ const createMockRedisClient = () => ({
|
||||
del: vi.fn().mockResolvedValue(1),
|
||||
exists: vi.fn().mockResolvedValue(0),
|
||||
keys: vi.fn().mockResolvedValue([]),
|
||||
scan: vi.fn().mockResolvedValue(['0', []]),
|
||||
|
||||
// Hash operations
|
||||
hget: vi.fn().mockResolvedValue(null),
|
||||
@@ -53,7 +54,14 @@ const createMockRedisClient = () => ({
|
||||
sadd: vi.fn().mockResolvedValue(1),
|
||||
srem: vi.fn().mockResolvedValue(1),
|
||||
smembers: vi.fn().mockResolvedValue([]),
|
||||
sismember: vi.fn().mockResolvedValue(0)
|
||||
sismember: vi.fn().mockResolvedValue(0),
|
||||
|
||||
// pipeline
|
||||
pipeline: vi.fn(() => ({
|
||||
del: vi.fn().mockReturnThis(),
|
||||
unlink: vi.fn().mockReturnThis(),
|
||||
exec: vi.fn().mockResolvedValue([])
|
||||
}))
|
||||
});
|
||||
|
||||
// Mock Redis connections to prevent connection errors in tests
|
||||
|
||||
Reference in New Issue
Block a user