Google Maps Bug
This commit is contained in:
@@ -51,6 +51,34 @@ export class CacheService {
|
||||
logger.error('Cache delete error', { key, error });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all keys matching the provided pattern (without namespace prefix).
|
||||
* Uses SCAN to avoid blocking Redis for large keyspaces.
|
||||
*/
|
||||
async deletePattern(pattern: string): Promise<void> {
|
||||
try {
|
||||
const namespacedPattern = this.prefix + pattern;
|
||||
let cursor = '0';
|
||||
|
||||
do {
|
||||
const [nextCursor, keys] = await redis.scan(
|
||||
cursor,
|
||||
'MATCH',
|
||||
namespacedPattern,
|
||||
'COUNT',
|
||||
100
|
||||
);
|
||||
cursor = nextCursor;
|
||||
|
||||
if (keys.length > 0) {
|
||||
await redis.del(...keys);
|
||||
}
|
||||
} while (cursor !== '0');
|
||||
} catch (error) {
|
||||
logger.error('Cache delete pattern error', { pattern, error });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const cacheService = new CacheService();
|
||||
|
||||
Reference in New Issue
Block a user