use of com.aerospike.client.Key in project XRTB by benmfaul.
the class RedissonClient method addList.
/**
* Add a list to the cach2k/Aerorpike
* @param id String. The name of the value.
* @param list List. The value to set, a list.
*/
public void addList(String id, List list) throws Exception {
if (ae == null) {
cacheDb.put(id, list);
return;
}
Key key = new Key("test", "cache", id);
Bin bin1 = new Bin("list", list);
ae.getClient().put(null, key, bin1);
}
use of com.aerospike.client.Key in project XRTB by benmfaul.
the class RedissonClient method set.
/**
* Set a key value as string with an expiration (No expiration set on cache2k, it is already set
* @param skey String. The key name.
* @param value String. The value.
* @throws Exception on aerorpike or cache errors.
*/
public void set(String set, String skey, Object value) throws Exception {
WritePolicy policy = new WritePolicy();
Key key = new Key("test", set, skey);
Bin bin1 = new Bin("value", value);
ae.getClient().put(null, key, bin1);
}
use of com.aerospike.client.Key in project XRTB by benmfaul.
the class RedissonClient method hgetAll.
/**
* Mimic a REDIS hgetAll operation.
* @param id String. They key to get.
* @return Map. The map stored at 'key'
* @throws Exception on aerospike/cache2k errors.
*/
public Map hgetAll(String id) {
if (ae == null) {
return (Map) cache.peek(id);
}
Key key = new Key("test", "cache", id);
Record record = null;
record = ae.getClient().get(null, key);
if (record == null) {
return null;
}
Map map = (Map) record.bins.get("value");
return map;
}
use of com.aerospike.client.Key in project XRTB by benmfaul.
the class RedissonClient method getMap.
/**
* Return the User object (as a map) from the database.
* @param name String. the name of the user.
* @return ConcurrentHashMap. The map representation of the user.
* @throws Exception on cache2k/aerorpike errors.
*/
public ConcurrentHashMap getMap(String name) throws Exception {
if (ae == null) {
return (ConcurrentHashMap) cacheDb.peek(name);
}
Key key = new Key("test", "database", "rtb4free");
Record record = null;
record = ae.getClient().get(null, key);
if (record == null) {
return new ConcurrentHashMap();
}
String content = (String) record.bins.get("map");
return mapper.readValue(content, ConcurrentHashMap.class);
}
use of com.aerospike.client.Key in project XRTB by benmfaul.
the class RedissonClient method addSet.
/**
* Ass a set of strings to the cache or aerospike. Used for blacklists.
* @param name String. The name of the set of strings.
* @param set Set. The set of strings.
* @throws Exception
*/
public void addSet(String name, Set set) throws Exception {
if (ae == null) {
cacheDb.put(name, set);
return;
}
Key key = new Key("test", "database", "rtb4free");
String data = mapper.writer().writeValueAsString(set);
Bin bin1 = new Bin("set", data);
ae.getClient().put(null, key, bin1);
}
Aggregations