Skip to content

Add ResetKeyMetadata method to resets per-key metadata.#414

Open
askomorokhov wants to merge 1 commit intoallegro:mainfrom
askomorokhov:add-method-to-reset-key-metadata
Open

Add ResetKeyMetadata method to resets per-key metadata.#414
askomorokhov wants to merge 1 commit intoallegro:mainfrom
askomorokhov:add-method-to-reset-key-metadata

Conversation

@askomorokhov
Copy link

Add ResetKeyMetadata Method to Clear Per-Key Request Counts
This PR introduces a ResetKeyMetadata method to BigCache, allowing users to reset per-key metadata such as request counts.
Similar to the existing Reset and ResetStats methods, ResetKeyMetadata helps clean up accumulated request statistics without affecting cached entries.

This is useful for applications that need to periodically clear usage metrics while retaining cache data.

Summary of changes:

  • Added BigCache.ResetKeyMetadata() and cacheShard.resetKeyMetadata() to clear per-key request counts.
  • Ensures thread safety by locking shards during reset.

}

// ResetKeyMetadata resets per-key metadata
func (c *BigCache) ResetKeyMetadata() error {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func (c *BigCache) ResetKeyMetadata() error {
func (c *BigCache) ResetKeysMetadata() error {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants