playframework / play-plugins

CachePlugin
444 stars 161 forks source link

Java-2.4: Use Redis module with Jedis #149

Closed johdah closed 9 years ago

johdah commented 9 years ago

How should this new module be used in Java? I am doing like this currently:

package actors
...
import com.typesafe.plugin.RedisPlugin;
import redis.clients.jedis.Jedis;
...
public class B2BPublisher extends UntypedActor {
    ...
    @Trace(dispatcher=true)
    @Override
    public void onReceive(final Object message) throws Exception {
        Jedis j = play.Play.application().plugin(RedisPlugin.class).jedisPool().getResource();
        try {
            j.incr("b2b.connections");
        } finally {
            play.Play.application().plugin(RedisPlugin.class).jedisPool().returnResource(j);
        }
        ...
    }
}
rmmeans commented 9 years ago

I'll see if I can get a hour or so soon to fix this up.

johdah commented 9 years ago

I added the code that was added to the README in a model but when I try to use the jedisPool I get att NullPointerException. Do I have to be in a controller to use the example?

johdah commented 9 years ago

Ah, the change isn't released yet? If so, when will we get a release?

rmmeans commented 9 years ago

Yeah, it hasn't been released yet. I also put in a pull for #154, waiting for that to be accepted and then I'm hoping typesafe will release 2.4.1 of the plugin.