Creating a simple cache with Redis for Phoenix Framework

653 views
Skip to first unread message

thoma...@gmail.com

unread,
Jul 15, 2015, 7:15:41 AM7/15/15
to phoeni...@googlegroups.com
Hi,

As a learning exercise, I want to implement a very simple cache in Redis in my project. I found this article which uses poolboy and eredis, and implements a pool of workers with a Supervisor module. Is this sufficient? I assume it'll work, but looking at the phoenix_pubsub_redis adapter, I see that two servers have been implemented.

So, should I write my own GenServer to handle interactions with Redis, or is that unnecessary and is adding the allowed queries (SET/GET/HSET/HGET/HMSET) to the Supervisor all I need to do?

Thanks in advance,
Thomas

Eric Meadows-Jönsson

unread,
Jul 16, 2015, 9:10:08 PM7/16/15
to phoeni...@googlegroups.com
The article seems to explain everything you need except they use some library for configuration instead of simply using the mix config. Phoenix uses multiple servers because that's what they need for solving the problem at hand. The article and phoenix uses different redis libraries so they may have different needs, for example Phoenix is wrapping the redo connection process to handle reconnects.

Create a GenServer if you need it, you will notice that as you are writing code. Just because you are wrapping the interface doesn't mean you have to create a GenServer, a simple module can wrap it.

Not sure what you mean by adding queries to a supervisor.

--
You received this message because you are subscribed to the Google Groups "phoenix-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phoenix-talk...@googlegroups.com.
To post to this group, send email to phoeni...@googlegroups.com.
Visit this group at http://groups.google.com/group/phoenix-talk.
To view this discussion on the web visit https://groups.google.com/d/msgid/phoenix-talk/5ac01aac-2ae0-40ec-ba20-8160f9e97411%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Eric Meadows-Jönsson
Reply all
Reply to author
Forward
0 new messages