Java Code Examples for net.spy.memcached.CachedData#getFlags()

The following examples show how to use net.spy.memcached.CachedData#getFlags() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KryoTranscoder.java    From hibernate4-memcached with Apache License 2.0 5 votes vote down vote up
@Override
public Object decode(CachedData data) {
    int flags = data.getFlags();

    byte[] decodedBytes = data.getData();

    boolean compressed = (flags & COMPRESS_FLAG) > 0;

    if (compressed) {
        decodedBytes = decompress(decodedBytes);
    }

    Kryo kryo = createKryo();
    return kryo.readClassAndObject(new Input(decodedBytes));
}
 
Example 2
Source File: EVCacheClientUtil.java    From EVCache with Apache License 2.0 5 votes vote down vote up
/**
 * TODO : once metaget is available we need to get the remaining ttl from an existing entry and use it 
 */
public EVCacheLatch add(EVCacheKey evcKey, CachedData cd, boolean shouldHashKey, Transcoder evcacheValueTranscoder, int timeToLive, Policy policy) throws Exception {
    if (cd == null) return null; 
    
    final EVCacheClient[] clients = _pool.getEVCacheClientForWrite();
    final EVCacheLatchImpl latch = new EVCacheLatchImpl(policy, clients.length - _pool.getWriteOnlyEVCacheClients().length, _appName);

    Boolean firstStatus = null;
    for (EVCacheClient client : clients) {
        String key = evcKey.getDerivedKey(client.isDuetClient());
        if (shouldHashKey) {
            final EVCacheValue val = new EVCacheValue(evcKey.getCanonicalKey(client.isDuetClient()), cd.getData(), cd.getFlags(), timeToLive, System.currentTimeMillis());
            cd = evcacheValueTranscoder.encode(val);
        }
        final Future<Boolean> f = client.add(key, timeToLive, cd, latch);
        if (log.isDebugEnabled()) log.debug("ADD : Op Submitted : APP " + _appName + ", key " + key + "; future : " + f + "; client : " + client);
        boolean status = f.get().booleanValue();
        if(!status) { // most common case
            if(firstStatus == null) {
                for(int i = 0; i < clients.length; i++) {
                    latch.countDown();
                }
                return latch;
            } else {
                return fixup(client, clients, evcKey, timeToLive, policy);
            }
        }
        if(firstStatus == null) firstStatus = Boolean.valueOf(status);
    }
    return latch;
}
 
Example 3
Source File: MemcacheClientWrapper.java    From simple-spring-memcached with MIT License 4 votes vote down vote up
@Override
public CachedObject encode(final Object o) {
    CachedData cachedData = transcoder.encode(o);
    return new CachedObjectImpl(cachedData.getFlags(), cachedData.getData());
}
 
Example 4
Source File: MemcacheClientWrapper.java    From simple-spring-memcached with MIT License 4 votes vote down vote up
@Override
public CachedObject encode(final Object o) {
    CachedData cachedData = transcoder.encode(o);
    return new CachedObjectImpl(cachedData.getFlags(), cachedData.getData());
}
 
Example 5
Source File: EVCacheClient.java    From EVCache with Apache License 2.0 4 votes vote down vote up
protected CachedData getEVCacheValue(String key, CachedData cData, int timeToLive) {
    final EVCacheValue val = new EVCacheValue(key, cData.getData(), cData.getFlags(), timeToLive, System.currentTimeMillis());
    return evcacheValueTranscoder.encode(val);
}