Expose the cache's current size as part of the API
Runtime
node.js
Runtime version
22
Module version
6.0.2
Used with
another framework
Any other relevant information
No response
What problem are you trying to solve?
I'm working on a project that uses @hapi/catbox with @hapi/catbox-memory to cache some API calls on servers. As this caching is very important for the project we would like to improve our monitoring and be able to capture the size of the cache in our metrics.
Do you have a new or modified API suggestion to solve the problem?
I've noticed that @hapi/catbox-memory has an internal byteSize property, but it's not exposed in the module's API (and not documented or included in the Typescript type definitions).
Would it be possible to expose this field? I would suggest a public getCacheSize() method for example.
I would happy to work on a pull request to add this, but wanted to make sure that not exposing this information was not by design.
Thank you!
I would probably just document the byteSize property + add it to the typings (with readonly). It is already informally part of the public API.