Comments (6)
There is only the latter way unless using sentinel or cluster mode.
w = Redis.new(url: 'redis://your-primary-endpoint')
r = Redis.new(url: 'redis://your-reader-endpoint')
w.set('foo', 1)
r.get('foo')
from redis-rb.
You can specify a reader endpoint like this:
r = Redis.new(url: 'rediss://your-reader-endpoint', reconnect_attempts: 10, reconnect_delay: 1.5, reconnect_delay_max: 10.0)
r.get('foo')
from redis-rb.
Thank you, @supercaracal, for your response, I'm aware of the reader endpoint. Is there a way to have a single Redis client connection that manages splitting read only calls between the primary endpoint and the reader endpoint and directs write calls to the primary endpoint? Or is it necessary to write special logic myself to handle multiple client connections (primary and reader) and directing calls to an endpoint based on the redis call?
from redis-rb.
Thanks for the info! Closing this.
from redis-rb.
@supercaracal Apologies for commenting on this closed ticket. But I'd like to ask for clarification.
I have an AWS Elasticache (cluster mode disabled) replication group with a write primary endpoint, and a readonly endpoint. In my scenario I am configuring Rails' cache store:
config.cache_store = :redis_cache_store, {
url: [
ENV['REDIS_WRITE_HOST'],
ENV['REDIS_READ_HOST'],
],
...
As it stands, I think I might run into problems with write operations being made on the readonly endpoint. You mention above that using cluster mode is a potential option. How would I leverage redis-clustering with ActiveSupport::Cache for my use-case? Thank you.
from redis-rb.
rcc = Redis::Cluster.new(nodes: "ENV['ELASTICACHE_ENDPOINT_URL']", replica: true, replica_affinity: :latency)
config.cache_store = :redis_cache_store, { redis: rcc }
The above setting might work for you if you use the redis gem version 5.*
or later. Also, Redis cluster (cluster mode is enabled in ElastiCache) has some constraints because it does sharding. If bulk processing commands such as MSET
, MGET
, pipelining, and transaction features are used in redis_cache_store
internally, some errors may occur. And clients need consideration of the replication delay. Sorry, I'm not familiar with redis_cache_store
codes.
https://github.com/rails/rails/blob/main/activesupport/lib/active_support/cache/redis_cache_store.rb
from redis-rb.
Related Issues (20)
- `.connection` method raises error in a Sentinel-based setup HOT 2
- redis-client requires Redis 6+ with HELLO command available HOT 2
- SORT_RO support HOT 1
- `ERR value is not an integer or out of range` after redis.ping HOT 4
- LMPOP not working HOT 5
- Unable to load application: TypeError: superclass mismatch for class Cluster HOT 7
- status
- Sentinel TLS: Sentinel TLS not supported HOT 5
- Configure Rails redis_cache_store with redis 5 HOT 1
- Unable to create redis cluster HOT 1
- Add support for redis Time Series module HOT 1
- OpenSSL::SSL::SSLError: SSL_write: unsupported method HOT 1
- Max number clients reached using subscribe_with_timeout HOT 2
- [Doc] Improve documentation about acceptable regular expressions pattern HOT 4
- Behavior of `pipelined { multi }` changed HOT 1
- 5.x seems to break IPv6 URL parsing HOT 1
- Redis::Cluster attempting Redis connection during asset precompilation HOT 5
- initialize': no implicit conversion of String into Integer (TypeError) HOT 1
- `:blpop` returns an exception when using sentinels HOT 3
- Proper documentation on how to setup rails to connect to a redis cluster for session management HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redis-rb.