Skip to content

Adds redis cache store#16

Closed
rmarronnier wants to merge 2 commits intoluckyframework:mainfrom
rmarronnier:adds-redis-cache-store
Closed

Adds redis cache store#16
rmarronnier wants to merge 2 commits intoluckyframework:mainfrom
rmarronnier:adds-redis-cache-store

Conversation

@rmarronnier
Copy link

I'm not sure about the status of Lucky Cache in the whole Lucky ecosystem and the plans about its use in other places but here is a claude code contribution adding a redis store to it.

@jwoertink
Copy link
Member

I'm 99.9% on board with this 👍 The only thing is, if we're going to have it, I'd rather move it to a separate shard. I can start a lucky_cache_redis_store shard if you want? I did this for Cable https://github.com/cable-cr/cable-redis and it basically follows the same pattern as Carbon https://github.com/luckyframework/carbon_sendgrid_adapter where the base shard just handles in-memory or basic data structure, then add-ons would just be a plugin with a separate shard. That would allow someone to make, say a RocksDB LuckyCache store, or whatever.

That's all because Lucky itself now requires this shard https://github.com/luckyframework/lucky/blob/7787f99baa8e7b8f6522fb427c9f19ef49137b05/shard.yml#L51-L53 so by adding this, it would force all Lucky apps to require Redis 😬

Let me know your thoughts, and if you agree, I can start a new shard and you can throw up a PR on to that one.

@rmarronnier
Copy link
Author

I'm not a big fan of tiny shards depending on a bigger parent one. Is there a way to do it the ruby way (https://guides.rubyonrails.org/caching_with_rails.html#activesupport-cache-rediscachestore) :

To get started, add the redis gem to your Gemfile:

gem "redis"
Copy
Finally, add the configuration in the relevant config/environments/*.rb file:

config.cache_store = :redis_cache_store, { url: ENV["REDIS_URL"] }

Then have the redis code in the main lucky cache shard. then ask the user to install the redis shard and require the redis store code.

If it's not possible / desirable, I'm ok for opening a new repo and taking care of it...

@jwoertink
Copy link
Member

Yeah, I totally get it, but if we add this in, then it means anyone using Lucky with https://github.com/stefanwille/crystal-redis or anyone who just doesn't want to use Redis at all will essentially locked in with no escape hatch to get away from it.

The thing with Ruby is that types can be stubbed easily for testing. If you type Redis in a spec for Crystal, then we have to have that shard as a development dependency at the very least, but that would still lead to compilation errors if anyone were using the other Redis shard since one uses a module and the other uses a class.

Unless there's something I'm missing, I'm pretty sure our only option would be to make it a separate shard.

@jwoertink
Copy link
Member

I've created a new report for this https://github.com/luckyframework/lucky_cache_redis_store we can move the code to that repo

@rmarronnier
Copy link
Author

Great, thanks. I'll open a PR.

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