}
@Override
public Result execute(Session session) throws StatementException {
AdvancedCache<Object, Object> cache = session.getCache(keyData.getCacheName()).getAdvancedCache();
Codec codec = session.getCodec();
boolean overwrite = true;
if (options.size() > 0) {
for (Option option : options) {
switch (option.toEnum(Options.class)) {
case CODEC: {
if (option.getParameter() == null) {
throw log.missingOptionParameter(option.getName());
} else {
codec = session.getCodec(option.getParameter());
}
break;
}
case IFABSENT: {
overwrite = false;
break;
}
}
}
}
Object encodedKey = codec.encodeKey(keyData.getKey());
Object encodedValue = codec.encodeValue(value);
Metadata metadata = codec.encodeMetadata(cache, expires, maxIdle);
if (overwrite) {
cache.put(encodedKey, encodedValue, metadata);
} else {
cache.putIfAbsent(encodedKey, encodedValue, metadata);