Comments (5)
Hey 👋 !!
Unfortunately, there is no configuration to send a PING
automatically, you have to implement it in your app, perhaps a process (GenServer
) that sends PING
s from time to time, and you can use MyApp.MyRedisCache.command!("some-rand-key", ["PING"])
(BTW, the random key is to ensure all connections in the pool can send the PING).
On the other hand, the adapter uses Redix
underneath, so you can use the option conn_opts
to configure Redix
, perhaps you can tweak the connection config (https://hexdocs.pm/redix/reconnections.html).
Let me know if that helps, I will stay tuned, thanks!!
from nebulex_redis_adapter.
Unfortunately I don't think Redix itself will help, from their docs they say:
If there are pending requests to Redix when a disconnection happens, the Redix functions will return {:error, %Redix.ConnectionError{reason: :disconnected}} to the caller. The caller is responsible to retry the request if interested.
So they are pushing the responsibility onto the consumer (which is library) to try the request again on disconnection. Redix does hold up it's end of the agreement though and we do see it reestablish the connection ready for the next cache request, which makes the timeout errors transient.
BTW, the random key is to ensure all connections in the pool can send the PING
This feels quite wasteful and why I was looking here for a solution as knowing you've hit all the connections in the pool isn't guaranteed. In a different project I worked on we wrapped the Redix connections in their own GenServer which was responsible for passing down the requests to Redix and also sending the PING
if no commands came in within a timeout. I can't get in between this library and the Redix connections though and it seems a shame to have to have to implement a new Nebulex adaptor to support it.
from nebulex_redis_adapter.
Yeah, I understand that but unfortunately, there is no immediate solution on the adapter itself, because the adapter doesn't have a GenServer
wrapping up the connection process as you describe, it uses the Redix
connection process directly, so trying to do something like we wrapped the Redix connections in their own GenServer which was responsible for passing down the requests to Redix and also sending the PING if no commands came in within a timeout
will mean a big refactoring in the adapter, I'm not saying is not worth it, in fact, it makes a lot of sense, but that would be more like a mid/long term feature. That's why I suggested implementing something simpler on top of the adapter.
from nebulex_redis_adapter.
👍 thank you, I worried this might cause a big refactor at this end, but thought it was worth raising to see if it was easy. I'll look into adding something at our end to mitigate this for the moment.
from nebulex_redis_adapter.
Yeah, this would be a nice feature. Since we are working on Nebulex v3, and there will be several changes and improvements in the Redis adapter regarding Redis Cluster and pool management, I will include it there, so let's keep the issue open. Thanks!!
from nebulex_redis_adapter.
Related Issues (20)
- Instrument the adapter with Telemetry events
- NebulexRedisAdapter does not implement `c:stats/0` HOT 1
- Add bootstrap server to run init and cleanup jobs (e.g.: attach/detach stats handler)
- Add Support for SSL HOT 3
- Raise an error when pipeline results contains one or more Redis errors
- Implement a Registry-based routing pool strategy
- Add `command/3` and `pipeline/3` extended functions
- Kubernetes Redis Cluster Returning MOVED HOT 10
- Allow deletion of multiple keys HOT 2
- Redis 7 issue HOT 2
- Configuring match_fun in conn_opts fails to build release HOT 4
- Configurable codec to encode/decode Redis keys and values
- Improve configuration for Redis Cluster mode
- Refactoring `Codec` to `Serializer`
- New Redis Cluster management strategy
- Allow passing Redis client options to `command` and `pipeline` functions
- Is Redis Sentinel support on the roadmap HOT 1
- Consistently getting MOVED error with a cluster HOT 2
- Potential RCE via :erlang.binary_to_term HOT 4
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 nebulex_redis_adapter.