I have to write a worker for whenever I’m setting the key in redis. But the function is maintaining a state here
def set(pid, key, value) do
GenServer.call(pid, {:set, key, value})
end
# handle call for set function
def handle_call({:set, key, value}, _from, state) do
reply = Redix.command(state, ["SET", key, value])
{:reply, reply, state}
end
So I have used Exq to process the background jobs. I have defined a module call SetWorker and
used this function to perform the redis set key
def perform(conn, key, value) do
Redix.command!(conn, ["SET", key, value])
end
Now I’ve define a function like this
def handle_call({:set, key, value}, _from, state) do
reply = Exq.enqueue(Exq, "q1", SetWorker, [key, value])
{:reply, reply, state}
end
but it’s giving me this error
Elixir.Gorm.SetWorker[baf417d7-14ac-455a-9038-ce4c21190098] start
[error] Process #PID<0.502.0> raised an exception
** (UndefinedFunctionError) function Gorm.SetWorker.perform/2 is undefined or private
(gorm) Gorm.SetWorker.perform("onetwdassddo", "three")
(exq) lib/exq/worker/server.ex:186: anonymous fn/4 in Exq.Worker.Server.dispatch_work/3
I don’t know what I’m doing wrong here.