Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build generic Active Support Cache adapter #533

Open
danmayer opened this issue May 1, 2024 · 2 comments
Open

Build generic Active Support Cache adapter #533

danmayer opened this issue May 1, 2024 · 2 comments

Comments

@danmayer
Copy link
Owner

danmayer commented May 1, 2024

We now have a number of adapters 2 redis, memcached, file, etc... If we built a good active support cache adapter it would work for all the traditional cache stores and AS::Cache has a file store as well as SolidCache which is a DB adapter so we would work for postgres, mysql, and sqlite (eventually).

This could reduce the number of custom adapters we need to maintain and possibly reduce the complexity.

It might not work for the HashRedisStore adapter which relies on LUA, so I would need to figure something out for that use case or rework how we use our cache store to not need the two very different methods coverband currently uses for coverage and storage.

@harm-matthias-harms
Copy link

I explored this for an hour. I'm not able and not sure how to proceed, here are my findings:

  • Adding an ActiveSupport::Cache adapter itself is kind of straightforward (I copied and modified the Redis adapter and its tests)
  • Configuring the store in config/coverband.rb is not straightforward, because Rails.cache does not exist at loading time (config.store = Coverband::Adapters::ActiveSupportCacheStore.new(Rails.cache)). Putting it in the initializer works fine.
  • Some other components, like view tracking, directly depend on the redis store (raw_store). So we probably not only need a new adapter, users can choose, but also rework some of the trackers. With ActiveSupport offering most of the current stores/adapters by default, it could be fine to make it the new default. But that would also be a very breaking change. https://api.rubyonrails.org/classes/ActiveSupport/Cache.html

@danmayer
Copy link
Owner Author

yeah it would definitely take some effort which is why I haven't had time for it. You are likely correct that it would end up being a breaking change... instead of raw_store with sets it would likely need to just serialize into JSON and use simple gets and sets so it might also be a bit slower....

Thanks for looking at it, I do hope to get back to this sometime.

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

No branches or pull requests

2 participants