mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-03 15:53:16 +03:00
Added a method to get all raw keys in the redis cache adapter
This allows for easy access to the raw, unprocessed, keys that a site has stored in the cache. These include all key prefixes.
This commit is contained in:
parent
ed38760c6d
commit
a50ef81148
@ -83,6 +83,14 @@ class AdapterCacheRedis extends BaseCacheAdapter {
|
||||
});
|
||||
}
|
||||
|
||||
async #getKeys() {
|
||||
const primaryNode = this.#getPrimaryRedisNode();
|
||||
if (primaryNode === null) {
|
||||
return [];
|
||||
}
|
||||
return await this.#scanNodeForKeys(primaryNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a recommended way to build cache key prefixes from
|
||||
* the cache-manager package. Might be a good contribution to make
|
||||
@ -144,12 +152,7 @@ class AdapterCacheRedis extends BaseCacheAdapter {
|
||||
*/
|
||||
async keys() {
|
||||
try {
|
||||
const primaryNode = this.#getPrimaryRedisNode();
|
||||
if (primaryNode === null) {
|
||||
return [];
|
||||
}
|
||||
const rawKeys = await this.#scanNodeForKeys(primaryNode);
|
||||
return rawKeys.map((key) => {
|
||||
return (await this.#getKeys()).map((key) => {
|
||||
return this._removeKeyPrefix(key);
|
||||
});
|
||||
} catch (err) {
|
||||
|
Loading…
Reference in New Issue
Block a user