redis队列操作

jedis-2.7.0.jar
添加

/**
   * Add the string value to the head (LPUSH) or tail (RPUSH) of the list stored at key. If the key
   * does not exist an empty list is created just before the append operation. If the key exists but
   * is not a List an error is returned.
   * 

* Time complexity: O(1) * @param key * @param strings * @return Integer reply, specifically, the number of elements inside the list after the push * operation. */ public Long rpush(final String key, final String... strings) { checkIsInMulti(); client.rpush(key, strings); return client.getIntegerReply(); } /** * Add the string value to the head (LPUSH) or tail (RPUSH) of the list stored at key. If the key * does not exist an empty list is created just before the append operation. If the key exists but * is not a List an error is returned. *

* Time complexity: O(1) * @param key * @param strings * @return Integer reply, specifically, the number of elements inside the list after the push * operation. */ public Long lpush(final String key, final String... strings) { checkIsInMulti(); client.lpush(key, strings); return client.getIntegerReply(); }

弹出

/**
   * Atomically return and remove the first (LPOP) or last (RPOP) element of the list. For example
   * if the list contains the elements "a","b","c" LPOP will return "a" and the list will become
   * "b","c".
   * 

* If the key does not exist or the list is already empty the special value 'nil' is returned. * @see #rpop(String) * @param key * @return Bulk reply */ public String lpop(final String key) { checkIsInMulti(); client.lpop(key); return client.getBulkReply(); } /** * Atomically return and remove the first (LPOP) or last (RPOP) element of the list. For example * if the list contains the elements "a","b","c" RPOP will return "c" and the list will become * "a","b". *

* If the key does not exist or the list is already empty the special value 'nil' is returned. * @see #lpop(String) * @param key * @return Bulk reply */ public String rpop(final String key) { checkIsInMulti(); client.rpop(key); return client.getBulkReply(); }

你可能感兴趣的:(#,redis,redis)