cds-caching 3.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cds-caching",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "A caching plugin for SAP CAP applications",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,7 @@ class CachingApiService extends cds.ApplicationService {
19
19
  // In MTX mode, lazily create cache entries on first dashboard / API access
20
20
  // (skipped at startup because there's no tenant context)
21
21
  if (isMultitenantMode()) {
22
- this.before('READ', ['Caches', 'Metrics', 'KeyMetrics'], async () => {
22
+ this.before('READ', ['Caches', 'Metrics', 'KeyMetrics', 'TagMetrics'], async () => {
23
23
  await this._ensureCacheEntries();
24
24
  });
25
25
  }
@@ -54,6 +54,21 @@ class CachingApiService extends cds.ApplicationService {
54
54
  }
55
55
  })
56
56
 
57
+ // Handle setTagMetricsEnabled action
58
+ this.on('setTagMetricsEnabled', async (req) => {
59
+ const { enabled } = req.data
60
+ const cacheService = await this._connectToCache(req);
61
+ const cache = this._cacheName(req);
62
+ try {
63
+ await cacheService.setTagMetricsEnabled(enabled)
64
+ req.info(`Tag metrics ${enabled ? 'enabled' : 'disabled'} for cache ${cache}`);
65
+ return true;
66
+ } catch (error) {
67
+ req.error(`Failed to set tag metrics enabled: ${error.message}`);
68
+ return false;
69
+ }
70
+ })
71
+
57
72
  // Handle getCacheEntries function
58
73
  this.on('getEntries', async (req) => {
59
74
  const cacheService = await this._connectToCache(req);
@@ -137,6 +152,15 @@ class CachingApiService extends cds.ApplicationService {
137
152
  return true;
138
153
  });
139
154
 
155
+ // Handle clearTagMetrics action
156
+ this.on('clearTagMetrics', async (req) => {
157
+ const cacheService = await this._connectToCache(req);
158
+ const cache = this._cacheName(req);
159
+ await cacheService.clearTagMetrics();
160
+ req.info(`Tag metrics cleared successfully: ${cache}`);
161
+ return true;
162
+ });
163
+
140
164
  // Handle clearMetrics action
141
165
  this.on('clearMetrics', async (req) => {
142
166
  const cacheService = await this._connectToCache(req);