Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.

Conversation

@marandaneto
Copy link
Contributor

@marandaneto marandaneto commented Jul 27, 2020

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

feat: rotate cache folder

💡 Motivation and Context

if the cache folder is full, we don't cache them anymore, ideally, we'd delete the oldest files making room for the new ones

💚 How did you test it?

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • All tests passing
  • No breaking changes

🔮 Next steps

@marandaneto marandaneto changed the base branch from master to 3.0.0 July 27, 2020 11:23
@marandaneto marandaneto changed the title feat/rotate cache folder feat: rotate cache folder Jul 27, 2020
@marandaneto marandaneto requested a review from a team July 27, 2020 11:53
Copy link
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

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

Other than a note on exists before deleting which we can discuss, :shipit:

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

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

Good job, maybe we can split up CacheStrategy as I suggested in a comment.

import java.util.Arrays;
import org.jetbrains.annotations.NotNull;

abstract class CacheStrategy {
Copy link
Member

Choose a reason for hiding this comment

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

m: I think we could split up this class into two classes. For me, we have two different responsibilities in here. We have some base functionality that both DiskCache and SessionCache need. And we have the sorting and deleting of the files. What about renaming CacheStrategy to something like SentryCache or BaseCache, although I'm not a fan of naming something base, ... and extracting sortFilesOldestToNewest and rotateCacheIfNeeded to a class called FileCacheStrategy or something similar. I'm a huge fan of composition over inheritance. So with the extracted class, we wouldn't have to create CustomCache in the CacheStrategyTest to be able to test the deleting and sorting of the files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure if it's worth creating another extra class to achieve this, actually only we wouldn't have to create CustomCache in the CacheStrategyTest is not enough argument as this is not added to the classpath, only on tests.

I still would need a class + an interface, ideally DiskCache and SessionCache will be merged very soon (when events become purely envelopes) and this class might lose its meaning, I mean, it'll be a single class anyway

opinions @bruno-garcia ?

Copy link
Member

Choose a reason for hiding this comment

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

I'm also a huge fan of composition over inheritence but IMHO this is a good use of inheritance.

Also, this stuff is internal so no need to over engineer this and break it apart. If it grows in the upcoming changes, we can refactor then.

That said, IMHO LGTM

Copy link
Member

Choose a reason for hiding this comment

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

I already stated my opinion and still with your arguments for keeping as it is I'm in favor of splitting it up, but I have no strong opinion on this as it's just a small class. I'm fine with keeping as it is. No need for further discussion IMO.

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

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

🥇 LGTM

@marandaneto marandaneto merged commit 14a5e29 into getsentry:3.0.0 Jul 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants