mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-11 22:13:20 +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
|
* This is a recommended way to build cache key prefixes from
|
||||||
* the cache-manager package. Might be a good contribution to make
|
* the cache-manager package. Might be a good contribution to make
|
||||||
@ -144,12 +152,7 @@ class AdapterCacheRedis extends BaseCacheAdapter {
|
|||||||
*/
|
*/
|
||||||
async keys() {
|
async keys() {
|
||||||
try {
|
try {
|
||||||
const primaryNode = this.#getPrimaryRedisNode();
|
return (await this.#getKeys()).map((key) => {
|
||||||
if (primaryNode === null) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
const rawKeys = await this.#scanNodeForKeys(primaryNode);
|
|
||||||
return rawKeys.map((key) => {
|
|
||||||
return this._removeKeyPrefix(key);
|
return this._removeKeyPrefix(key);
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
Loading…
Reference in New Issue
Block a user