コード例 #1
0
 @Override
 public void remove(long[] keys, KCallback<Throwable> error) {
   int nbKeys = keys.length / 3;
   String[] elems = new String[nbKeys];
   for (int i = 0; i < nbKeys; i++) {
     elems[i] = KContentKey.toString(keys, i);
   }
   jedis.del(elems);
 }
コード例 #2
0
 @Override
 public void get(long[] keys, KCallback<String[]> callback) {
   int nbKeys = keys.length / 3;
   String[] flatKeys = new String[nbKeys];
   for (int i = 0; i < nbKeys; i++) {
     flatKeys[i] = KContentKey.toString(keys, i);
   }
   List<String> values = jedis.mget(flatKeys);
   if (callback != null) {
     callback.on(values.toArray(new String[values.size()]));
   }
 }
コード例 #3
0
 @Override
 public synchronized void put(
     long[] p_keys, String[] p_values, KCallback<Throwable> p_callback, int excludeListener) {
   int nbKeys = p_keys.length / 3;
   String[] elems = new String[nbKeys * 2];
   for (int i = 0; i < nbKeys; i++) {
     elems[(i * 2)] = KContentKey.toString(p_keys, i);
     elems[(i * 2) + 1] = p_values[i];
   }
   if (jedis != null) {
     jedis.mset(elems);
   }
   KMessage events = new Message();
   events.setType(Message.EVENTS_TYPE);
   events.setKeys(p_keys);
   jedis.publish("kmf", events.save());
   if (p_callback != null) {
     p_callback.on(null);
   }
 }
コード例 #4
0
 @Override
 public void atomicGetIncrement(long[] key, KCallback<Short> cb) {
   String result = jedis.get(KContentKey.toString(key, 0));
   short nextV;
   short previousV;
   if (result != null) {
     try {
       previousV = Short.parseShort(result);
     } catch (Exception e) {
       e.printStackTrace();
       previousV = Short.MIN_VALUE;
     }
   } else {
     previousV = 0;
   }
   if (previousV == Short.MAX_VALUE) {
     nextV = Short.MIN_VALUE;
   } else {
     nextV = (short) (previousV + 1);
   }
   // TODO use the nativeInc method
   jedis.set(key.toString(), "" + nextV);
   cb.on(previousV);
 }