How retrieve all data stored in In-memory cache via cache-manager

Viewed 1104
1 Answers

There is a store property in cacheManager from which you can get all keys and get the data.

@Get('get-all-data')
async getData() {
  //Get all keys
  const keys = await this.cacheManager.store.keys();

  //Loop through keys and get data
  const allData: { [key: string]: any } = {};
  for (const key of keys) {
    allData[key] = await this.cacheManager.get(key);
  }
  return allData;
}
Related