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

added support for redis connection pools #839

Closed

Conversation

j-castellanos
Copy link

To solve this issue #609 in a DRY way I simply wrap all the public methods in the existing redis adapter

@j-castellanos
Copy link
Author

@jnunemaker could you rerun the failed test?

@bkeepers
Copy link
Collaborator

@j-castellanos Thanks for the PR!

In #826 (review) I offered a couple suggestions of how I think we should approach connection pool support. I don't really love having different adapters Redis depending on if you're using the client directly or a connection pool. I'd rather see Redis and RedisCache updated to work directly with a client or a pool internally, or add a generic ConnectionPool adapter as attempted in #835.

I don't feel strongly between those two approaches, but I would like to make sure we add connection pool support to both Redis and RedisCache at the same time.

Thoughts?

@j-castellanos
Copy link
Author

@bkeepers how is this?

def initialize(client_or_pool = nil, key_prefix: nil)
@pool = nil
@client = nil
if client_or_pool.respond_to?(:with)
Copy link
Author

Choose a reason for hiding this comment

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

Maybe is_a?(ConnectionPool) might be better

removing idea

fixing specs
@j-castellanos
Copy link
Author

@jnunemaker @bkeepers thoughts on this one?

@jnunemaker
Copy link
Collaborator

I don't want to add more methods to Flipper::Adapter. I think I'd just make redis and redis cache work with a client or a pool. That seems like easiest way.

def client(&block)
  # if client, then yield that, if connection pool then call with and yield client
end 

# then change all methods that use @client to use client { |c| c.blah... }

We could just abstract a method for getting a client and if adapter was initialized with pool it will use with and a block. If initialize with a client the client would just be used.

I'll make a note to whip something together or anyone else is free to try sooner.

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.

3 participants