Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- RFID
- Kuala Lumpur
- Software Engineering
- comic agile
- Spain
- web
- Book
- France
- Programming
- Italy
- Book review
- management
- Linux
- agile
- programming_book
- django
- history
- program
- Java
- erlang
- Malaysia
- hadoop
- Python
- MySQL
- psychology
- leadership
- essay
- ubuntu
- QT
- hbase
Archives
- Today
- Total
Install Jedis on Ubuntu 10.04 본문
- https://github.com/xetorthio/jedis/wiki
- Simpler than JRedis (https://github.com/alphazero/jredis)
- Prerequisite
- Redis installation: http://redis.io/
- Apache commons pool jar file: http://commons.apache.org/pool/download_pool.cgi
installation
$ git clone git://github.com/xetorthio/jedis.git
$ cd jedis
jedis$ mvn compile
# execute two redis servers for test
jedis$ redis-server jedis/conf/redis.conf
jedis$ redis-server jedis/conf/redis2.conf
jedis$ mvn package
basic usage
/* javac -cp ../jedis/target/jedis-2.0.1-SNAPSHOT.jar:./commons-pool-1.5.6/commons-pool-1.5.6.jar TestJedis.java java -cp .:../jedis/target/jedis-2.0.1-SNAPSHOT.jar:./commons-pool-1.5.6/commons-pool-1.5.6.jar TestJedis */ import java.util.Set; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; import redis.clients.jedis.JedisPoolConfig; public class TestJedis { public static void main(String[] args) { JedisPool pool = new JedisPool(new JedisPoolConfig(), "localhost"); Jedis jedis = pool.getResource(); try { /// ... do stuff here ... for example jedis.set("foo", "bar"); String foobar = jedis.get("foo"); System.out.println("foobar = " + foobar); jedis.zadd("sose", 0, "car"); jedis.zadd("sose", 0, "bike"); Set<String> sose = jedis.zrange("sose", 0, -1); System.out.println("sose = " + sose); } finally { /// ... it's important to return the Jedis instance to the pool //once you've finished using it pool.returnResource(jedis); } /// ... when closing your application: pool.destroy(); } }
Comments