Exemplo n.º 1
0
 @Override
 public boolean remove(Object key) throws CacheLoaderException {
   if (trace) log.tracef("remove(\"%s\") ", key);
   Cassandra.Client cassandraClient = null;
   try {
     cassandraClient = dataSource.getConnection();
     Map<ByteBuffer, Map<String, List<Mutation>>> mutationMap =
         new HashMap<ByteBuffer, Map<String, List<Mutation>>>();
     remove0(ByteBufferUtil.bytes(hashKey(key)), mutationMap);
     cassandraClient.batch_mutate(mutationMap, writeConsistencyLevel);
     return true;
   } catch (Exception e) {
     log.errorRemovingKey(key, e);
     return false;
   } finally {
     dataSource.releaseConnection(cassandraClient);
   }
 }
Exemplo n.º 2
0
 private void store0(
     InternalCacheEntry entry, Map<ByteBuffer, Map<String, List<Mutation>>> mutationMap)
     throws IOException, UnsupportedKeyTypeException {
   Object key = entry.getKey();
   if (trace) log.tracef("store(\"%s\") ", key);
   String cassandraKey = hashKey(key);
   try {
     addMutation(
         mutationMap,
         ByteBufferUtil.bytes(cassandraKey),
         config.entryColumnFamily,
         ByteBuffer.wrap(entryColumnPath.getColumn()),
         ByteBuffer.wrap(marshall(entry)));
     if (entry.canExpire()) {
       addExpiryEntry(cassandraKey, entry.getExpiryTime(), mutationMap);
     }
   } catch (InterruptedException ie) {
     if (trace) log.trace("Interrupted while trying to marshall entry");
     Thread.currentThread().interrupt();
   }
 }