Search in sources :

Example 6 with Bin

use of com.aerospike.client.Bin 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);
}
Also used : Bin(com.aerospike.client.Bin) Key(com.aerospike.client.Key) WritePolicy(com.aerospike.client.policy.WritePolicy)

Example 7 with Bin

use of com.aerospike.client.Bin 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);
}
Also used : Bin(com.aerospike.client.Bin) Key(com.aerospike.client.Key)

Example 8 with Bin

use of com.aerospike.client.Bin in project XRTB by benmfaul.

the class RedissonClient method hmset.

/**
 * Mimic a REDIS mhset operation.
 * @param id String. The key of the map.
 * @param m Map. The map to set.
 */
public void hmset(String id, Map m) throws Exception {
    if (ae == null) {
        cache.put(id, m);
        return;
    }
    Key key = new Key("test", "cache", id);
    Bin bin1 = new Bin("value", m);
    ae.getClient().put(null, key, bin1);
}
Also used : Bin(com.aerospike.client.Bin) Key(com.aerospike.client.Key)

Example 9 with Bin

use of com.aerospike.client.Bin 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);
}
Also used : Bin(com.aerospike.client.Bin) Key(com.aerospike.client.Key)

Example 10 with Bin

use of com.aerospike.client.Bin in project XRTB by benmfaul.

the class RedissonClient method addMap.

/**
 * Add a map (a user map) to the the cache or aerorspike.
 * @param name String. The name of the map.
 * @param map Map. The map of the User object.
 * @throws Exception on cache2k/aerospike errors
 */
public void addMap(String name, Map map) throws Exception {
    if (ae == null) {
        cacheDb.put(name, map);
        return;
    }
    Key key = new Key("test", "database", "rtb4free");
    String data = mapper.writer().writeValueAsString(map);
    Bin bin1 = new Bin("map", data);
    ae.getClient().put(null, key, bin1);
}
Also used : Bin(com.aerospike.client.Bin) Key(com.aerospike.client.Key)

Aggregations

Bin (com.aerospike.client.Bin)151 Key (com.aerospike.client.Key)129 Record (com.aerospike.client.Record)70 Test (org.junit.Test)54 AerospikeException (com.aerospike.client.AerospikeException)34 ArrayList (java.util.ArrayList)31 WritePolicy (com.aerospike.client.policy.WritePolicy)27 HashMap (java.util.HashMap)22 Value (com.aerospike.client.Value)20 List (java.util.List)15 BeforeClass (org.junit.BeforeClass)14 Map (java.util.Map)13 Policy (com.aerospike.client.policy.Policy)12 IndexTask (com.aerospike.client.task.IndexTask)11 WriteListener (com.aerospike.client.listener.WriteListener)5 RegisterTask (com.aerospike.client.task.RegisterTask)5 AbstractMap (java.util.AbstractMap)4 TreeMap (java.util.TreeMap)4 CTX (com.aerospike.client.cdt.CTX)3 BitPolicy (com.aerospike.client.operation.BitPolicy)3