use of com.google.appengine.api.memcache.InvalidValueException in project Cached-Datastore by Emperorlou.
the class CachedDatastoreService method incrementStat.
protected double incrementStat(String statKey, double amount) {
while (true) {
IdentifiableValue identifiable = mc.getIdentifiable(statKey);
if (identifiable == null) {
throw new InvalidValueException("Cannot increment a stat that starts from null.");
} else {
double newValue = (((Double) identifiable.getValue()) + amount);
boolean success = mc.putIfUntouched(statKey, identifiable, newValue);
if (success)
return newValue;
}
}
}
use of com.google.appengine.api.memcache.InvalidValueException in project pratilipi by Pratilipi.
the class MemcacheGaeImpl method get.
@SuppressWarnings("unchecked")
@Override
public <K, T extends Serializable> T get(K key) {
try {
Cache cache = CacheManager.getInstance().getCacheFactory().createCache(Collections.emptyMap());
T value = (T) cache.get(key);
if (value == null)
logger.log(Level.INFO, "Cache Miss: " + key);
// logger.log( Level.INFO, "Cache Hit: " + key );
return value;
} catch (InvalidValueException | ClassCastException e) {
logger.log(Level.SEVERE, "Failed to typecaste cached value to required type.", e);
return null;
} catch (CacheException e) {
logger.log(Level.SEVERE, "Failed to create cache instance.", e);
return null;
}
}
Aggregations