forked from adrienmo/eredis_cluster
-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
Hello,
I'm using eredis_cluster
with Google Cloud Memorystore for Redis Cluster, which uses their IAM Auth instead of a static password. Basically I need to generate a token (which usually expires in 1 hour) and use it as password
for eredis_cluster
. An authenticated connection is valid for 12 hours.
How would I "refresh" connections, i.e. generate a new token and then reconnect with it so my redis connections won't become invalid? I'm using eredis_cluster
in an Elixir application (a Phoenix server) inside a Genserver like below:
defmodule MyApp.GlobalRedis do
use GenServer
@pool_size 5
@cluster_name :global_redis_cluster
def start_link(opts \\ []) do
GenServer.start_link(__MODULE__, opts, name: __MODULE__)
end
@impl true
def init(_init_arg) do
host = ...
port = ...
password = Goth.fetch!(MyApp.Goth).token
:eredis_cluster.connect(@cluster_name, [{host, port}],
password: password,
pool_size: @pool_size,
pool_max_overflow: 0,
socket_options: [
send_timeout: 500,
send_timeout_close: true,
nodelay: true,
keepalive: true
]
)
end
end
Metadata
Metadata
Assignees
Labels
No labels