DirectMemory Simple Usage

Add a dependency to the DirectMemory cache artifact:

  <dependency>
    <groupId>org.apache.directmemory.server</groupId>
    <artifactId>directmemory-cache</artifactId>
    <version>0.1-incubating</version>
  </dependency>

Create your CacheService instance:

  CacheService<Object, Object> cacheService = new DirectMemory<Object, Object>()
    .setNumberOfBuffers( 10 )
    .setSize( 1000 )
    .setInitialCapacity( 100000 )
    .setConcurrencyLevel( 4 )
    .newCacheService();

Use the cache service to store object, Those methods returns a Pointer if this pointer is null your object has not been stored:

  put( K key, V value )
  put( K key, V value, int expiresIn )

Retrieve an Object from the cache service:

  V retrieve( K key );

Clear at the end of usage

  cacheService.clear()