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

with_namespace does not seem to be applying the namespace to pipelined commands with redis > 4.5.1 #362

Open
alex-jobber opened this issue Jul 21, 2023 · 0 comments

Comments

@alex-jobber
Copy link

alex-jobber commented Jul 21, 2023

Hello! I was recently looking into updating our redis gem past 4.5.1 and noticed that when using the updated pipelined syntax the namespace was not applied. I tried this with redis-store 1.9.0, 1.9.1, and 1.9.2.

It's possible we are no longer using redis-pool as intended, and if so would appreciate direction on that (this comment makes me think so but I am not sure).

Stripping away as much as possible (including additional commands inside the pipelined block) this is essentially what we are doing. The call to incrby (and other commands inside the pipelined block) does not include the namespace. ConnectionPool

redis_conn = proc { Redis::Store.new options }
redis_pool = ConnectionPool.new(
  size: pool_size,
  &redis_conn
)

redis_pool.with do |connection|
  connection.with_namespace(CACHE_NAMESPACE) do |namespaced_connection|
    namespaced_connection.pipelined do |pipeline|
      pipeline.incrby(key, amount)
    end
  end
end

Previously we would use the namespaced_connection directly inside the pipelined block, but that is now deprecated.

redis_pool.with do |connection|
  connection.with_namespace(CACHE_NAMESPACE) do |namespaced_connection|
    namespaced_connection.pipelined do
      namespaced_connection.incrby(key, amount)
    end
  end
end

I figured out we couldn't go past redis 4.5.1 with testing and when I was looking at this line, but I am not entirely sure how I could get namespacing applied to a pipelined block.

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

1 participant