Search in sources :

Example 41 with Key

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

the class CookieList method main.

public static void main(String[] args) throws Exception {
    int i = 0;
    String aero = "localhost:3000";
    String setName = null;
    String mapName = null;
    String op = null;
    String name = null;
    String file = null;
    boolean range = false;
    AerospikeClient client = new AerospikeClient("localhost", 3000);
    Key key = new Key("test", "database", "rtb4free");
    ArrayList<String> list = new ArrayList<String>();
    TreeSet set = new TreeSet();
    for (i = 0; i < 100000; i++) {
        list.add(Integer.toString(i));
        set.add(Integer.toString(i));
    }
    Bin bin1 = new Bin("c1x-cookies", set);
    client.put(null, key, bin1);
    System.out.println("Done!");
    Record record = client.get(null, key);
    long time = System.currentTimeMillis();
    Set<String> receivedList = (Set<String>) record.getValue("c1x-cookies");
    receivedList.contains("99999");
    System.out.println(System.currentTimeMillis() - time);
    System.out.println("Received List = " + receivedList.size());
}
Also used : AerospikeClient(com.aerospike.client.AerospikeClient) Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Bin(com.aerospike.client.Bin) ArrayList(java.util.ArrayList) TreeSet(java.util.TreeSet) Record(com.aerospike.client.Record) Key(com.aerospike.client.Key)

Example 42 with Key

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

the class AeroRange method main.

public static void main(String[] args) throws Exception {
    AerospikeClient client = new AerospikeClient(args[0], 3000);
    String skey = "accountingsystem";
    Key key = new Key("test", "cache", skey);
    while (true) {
        Record record = null;
        record = client.get(null, key);
        String value = (String) record.bins.get("value");
        System.out.println(value);
        Thread.sleep(1000);
    }
}
Also used : AerospikeClient(com.aerospike.client.AerospikeClient) Record(com.aerospike.client.Record) Key(com.aerospike.client.Key)

Example 43 with Key

use of com.aerospike.client.Key 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 44 with Key

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

the class RedissonClient method del.

/**
	 * Delete a bid key from the cache/aerospile.
	 * @param skey String. The key name.
	 * @throws Exception on Aerospike/cache errors.
	 */
public void del(String skey) {
    if (ae == null) {
        cache.remove(skey);
        return;
    }
    Key key = new Key("test", "cache", skey);
    ae.getClient().delete(null, key);
}
Also used : Key(com.aerospike.client.Key)

Example 45 with Key

use of com.aerospike.client.Key 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

Key (com.aerospike.client.Key)201 Record (com.aerospike.client.Record)104 Bin (com.aerospike.client.Bin)103 Test (org.junit.Test)79 ArrayList (java.util.ArrayList)49 AerospikeException (com.aerospike.client.AerospikeException)47 Value (com.aerospike.client.Value)37 HashMap (java.util.HashMap)32 List (java.util.List)31 WritePolicy (com.aerospike.client.policy.WritePolicy)21 Map (java.util.Map)15 Statement (com.aerospike.client.query.Statement)10 BeforeClass (org.junit.BeforeClass)10 Policy (com.aerospike.client.policy.Policy)9 RecordSet (com.aerospike.client.query.RecordSet)8 IndexTask (com.aerospike.client.task.IndexTask)8 Collections.singletonList (java.util.Collections.singletonList)6 AerospikeClient (com.aerospike.client.AerospikeClient)5 BatchRead (com.aerospike.client.BatchRead)5 MapPolicy (com.aerospike.client.cdt.MapPolicy)5