perf(core): replace md5 cache key with xxhash64 (#13974)

* perf(core): replace md5 cache key with xxhash64

* test: add test case for cache TTL key
This commit is contained in:
Tony
2023-12-07 00:58:39 +08:00
committed by GitHub
parent 360fc48d90
commit 3c8ccd948e
5 changed files with 30 additions and 8 deletions
+14 -1
View File
@@ -13,7 +13,7 @@ beforeAll(() => {
afterEach(() => {
delete process.env.CACHE_TYPE;
jest.resetModules();
server.close();
server?.close();
});
afterAll(() => {
@@ -203,4 +203,17 @@ describe('cache', () => {
expect(e.message).toContain('Cache key must be a string');
}
});
it('throws TTL key', async () => {
process.env.CACHE_TYPE = 'redis';
const app = require('../../lib/app');
try {
await app.context.cache.get('rsshub:cacheTtl:mock');
} catch (e) {
expect(e.message).toContain('reserved for the internal usage');
} finally {
await app.context.cache.clients.redisClient.quit();
}
});
});