use of org.directmemory.memory.Pointer in project DirectMemory by raffaeleguidi.
the class CacheConcurrentTests method get.
private void get(String key) {
Pointer p = Cache.getPointer(key);
@SuppressWarnings("unused") byte[] check = Cache.retrieveByteArray(key);
read.incrementAndGet();
if (p != null) {
got.incrementAndGet();
byte[] payload = MemoryManager.retrieve(p);
if ((new String(payload)).startsWith(key))
good.incrementAndGet();
else
bad.incrementAndGet();
} else {
missed.incrementAndGet();
}
}
use of org.directmemory.memory.Pointer in project DirectMemory by raffaeleguidi.
the class CacheLightConcurrentTest method getAndRetrieve.
private void getAndRetrieve(String key) {
Pointer p = Cache.getPointer(key);
@SuppressWarnings("unused") byte[] check = Cache.retrieveByteArray(key);
read.incrementAndGet();
if (p != null) {
got.incrementAndGet();
byte[] payload = MemoryManager.retrieve(p);
if ((new String(payload)).startsWith(key))
good.incrementAndGet();
else
bad.incrementAndGet();
} else {
missed.incrementAndGet();
}
}
use of org.directmemory.memory.Pointer in project DirectMemory by raffaeleguidi.
the class ConcurrentTests method retrieveCatchThemAll.
@BenchmarkOptions(benchmarkRounds = 1000000, warmupRounds = 0, concurrency = 100)
@Test
public void retrieveCatchThemAll() {
String key = "test-" + (rndGen.nextInt(entries) + 1);
Pointer p = map.get(key);
read.incrementAndGet();
if (p != null) {
got.incrementAndGet();
byte[] payload = mem.retrieve(p);
if (key.equals(new String(payload)))
good.incrementAndGet();
else
bad.incrementAndGet();
} else {
logger.info("did not find key " + key);
missed.incrementAndGet();
}
}
use of org.directmemory.memory.Pointer in project DirectMemory by raffaeleguidi.
the class Cache method updateByteArray.
public static Pointer updateByteArray(String key, byte[] payload) {
Pointer p = map.get(key);
p = MemoryManager.update(p, payload);
return p;
}
use of org.directmemory.memory.Pointer in project DirectMemory by raffaeleguidi.
the class Cache method putByteArray.
public static Pointer putByteArray(String key, byte[] payload, int expiresIn) {
Pointer ptr = MemoryManager.store(payload, expiresIn);
map.put(key, ptr);
return ptr;
}
Aggregations