Hi dear
> Jedis is not thread safe and you shouldn't use the same instance in
> different threads.
i am using grails right now, and jedis instance is in a service, which
provide methods using this instance and these methods accessed by
Controller, that means for each client there is a thread accessing the
instance
i think making these methods synchronized will work BUT with horrible
performance degradation as syncing is not working good for large no.
of threads
> 1. You create a Jedis and connect it
> 2. Execute some commands
> 3. Leave it open and unused for a while
> 4. Try to execute another command
yes this is how i did things
i think that creating a jedis instance every time or calling
disconnect and re- connect() for the next command is expensive as
connect:
if (!isConnected()) {
socket = new Socket(host, port);
socket.setSoTimeout(timeout);
outputStream = new RedisOutputStream(socket.getOutputStream());
inputStream = new RedisInputStream(socket.getInputStream());
}
it create a new socket, and inputStream and outputStream which is
expensive in terms of JVM resource utilization
i am using redis to develop an web analytics solution which will have
may be hundreds or thaosands of hits per second (may be more,and this
is why i choose redis)
so creating a socket each time is not a wise solution
as a temporary solution , i made a schedualer that create a new Jedis
instance every minute , that means a new Socket every minute
But if you think that there is a better solution , please let me know
i do not used JedisPool b4 as i thought it is used for sharding only
and i have a one Redis server for now
if this is the way to go, please write a sample code, that show best
practice for using the library and does not exhaust the JVM resources
On Oct 13, 1:20 am, Jonathan Leibiusky <
ionat...@gmail.com> wrote:
> Sorry about the lack of documentation, I'm actually working on this, should
> have something out there this week.
>