Reputation: 266988
In the jedis docs it says to create a pool:
JedisPool pool = new JedisPool(new JedisPoolConfig(), "localhost");
And that I should be storing this statically somewhere.
I know spring has a spring-data library that is in development, but I just want to use the library w/o that for now.
Where do you suggest I create this static reference to the pool?
Should I create a JedisService and then have a public method that returns this pool?
Do I do this using the singleton pattern? lock before returning?
Upvotes: 1
Views: 1422
Reputation: 308753
If you're using Spring, you can't use new
and have the object under Spring's control. Make it a Spring bean and initialize it using a factory method.
You declare beans in your Spring application context XML (or using annotations, if you're so inclined):
<bean id="jedisPool" class="foo.bar.JedisPool">
<constructor-arg ref="jedisPoolCofig"/>
<constructor-arg value="localhost"/
</bean>
Upvotes: 1