Skip to content

Build generic Active Support Cache adapter #533

Open
@danmayer

Description

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.

Activity

harm-matthias-harms

harm-matthias-harms commented on Aug 22, 2024

@harm-matthias-harms

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

danmayer commented on Aug 29, 2024

@danmayer
OwnerAuthor

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Build generic Active Support Cache adapter · Issue #533 · danmayer/coverband