Skip to content

Conversation

yss14
Copy link

@yss14 yss14 commented Jul 3, 2025

As already outlined in #71, in my opinion the current naming of the deleteByTag operation is a bit misleading, since it doesn't hard delete cache entries by tag matching, but rather expires them. That's why I included a commit in this PR renaming the current deleteByTag operation to expireByTag to be compliant with the naming of the key based operations.
I'm aware that this means a breaking change in the API and I'm open to discuss how to resolve this if a major release is to avoid.

The main concern of this PR is the implementation of a new operation deleteByTag, which performs a "kind of" hard delete via a lazy deletion logic via invalidation timestamps similar to the approach of the expireByTag (previously deleteByTag) operation.
Here I'm also open to discuss the best approach for the hard deletion logic.

Copy link

changeset-bot bot commented Jul 3, 2025

⚠️ No Changeset found

Latest commit: ce6b2c1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

]).then(async ([isHardDeleted, isTagInvalidated]) => {
if (isHardDeleted) {
// Immediately delete from all layers and return false
await this.#deleteFromAllLayers(item.entry.getKey())
Copy link
Author

Choose a reason for hiding this comment

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

Not super happy about performing a side-effect in a method which main purpose is to return a boolean indicating whether an entry is still valid.
If you have a better idea let me know :)

Copy link
Owner

Choose a reason for hiding this comment

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

Not a huge problem imo. We are also doing this in isTagInvalidated. But agree with you that its semantically incorrect

@yss14 yss14 marked this pull request as ready for review July 3, 2025 19:59
@Julien-R44
Copy link
Owner

Thanks a lot for the PR and sorry forlate reply, i have been pretty busy these last weeks...

Just a quick ( and maybe naive) question: instead of doing a double round-trip to check hard and soft tag keys separately, what about storing some metadata inside the tag value?

Something like:

await this.stack.set('___bc:t:users', { timestamp, type: 'hard' | 'soft' })

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