Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public class Cache
{

private static CacheService cacheService = new CacheServiceImpl();
private static CacheService<String, Object> cacheService = new CacheServiceImpl<String, Object>();

// olamy chicken and eggs isssue
// private static CacheService cacheService = new CacheServiceImpl( getMemoryManager());
Expand All @@ -52,22 +52,22 @@ public static void init( int numberOfBuffers, int size )
init( numberOfBuffers, size, CacheService.DEFAULT_INITIAL_CAPACITY, CacheService.DEFAULT_CONCURRENCY_LEVEL );
}

public static Pointer putByteArray( String key, byte[] payload, int expiresIn )
public static Pointer<Object> putByteArray( String key, byte[] payload, int expiresIn )
{
return cacheService.putByteArray( key, payload, expiresIn );
}

public static Pointer putByteArray( String key, byte[] payload )
public static Pointer<Object> putByteArray( String key, byte[] payload )
{
return cacheService.putByteArray( key, payload );
}

public static Pointer put( String key, Object object )
public static Pointer<Object> put( String key, Object object )
{
return cacheService.put( key, object );
}

public static Pointer put( String key, Object object, int expiresIn )
public static Pointer<Object> put( String key, Object object, int expiresIn )
{
return cacheService.put( key, object, expiresIn );
}
Expand All @@ -82,7 +82,7 @@ public static Object retrieve( String key )
return cacheService.retrieve( key );
}

public static Pointer getPointer( String key )
public static Pointer<Object> getPointer( String key )
{
return cacheService.getPointer( key );
}
Expand All @@ -92,7 +92,7 @@ public static void free( String key )
cacheService.free( key );
}

public static void free( Pointer pointer )
public static void free( Pointer<Object> pointer )
{
cacheService.free( pointer );
}
Expand Down Expand Up @@ -123,7 +123,7 @@ public static long entries()
return cacheService.entries();
}

public static void dump( OffHeapMemoryBuffer mem )
public static void dump( OffHeapMemoryBuffer<Object> mem )
{
cacheService.dump( mem );
}
Expand All @@ -138,14 +138,14 @@ public static Serializer getSerializer()
return cacheService.getSerializer();
}

public static MemoryManagerService getMemoryManager()
public static MemoryManagerService<Object> getMemoryManager()
{
return cacheService.getMemoryManager();
}

public static Pointer allocate( String key, int size )
public static Pointer<Object> allocate( String key, int size )
{
return cacheService.allocate( key, size );
return cacheService.allocate( key, Object.class, size );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

import java.util.concurrent.ConcurrentMap;

public interface CacheService
public interface CacheService<K, V>
{

public static int DEFAULT_CONCURRENCY_LEVEL = 4;
Expand All @@ -39,23 +39,23 @@ public interface CacheService

void scheduleDisposalEvery( long l );

Pointer putByteArray( String key, byte[] payload, int expiresIn );
Pointer<V> putByteArray( K key, byte[] payload, int expiresIn );

Pointer putByteArray( String key, byte[] payload );
Pointer<V> putByteArray( K key, byte[] payload );

Pointer put( String key, Object object );
Pointer<V> put( K key, V value );

Pointer put( String key, Object object, int expiresIn );
Pointer<V> put( K key, V value, int expiresIn );

byte[] retrieveByteArray( String key );
byte[] retrieveByteArray( K key );

Object retrieve( String key );
Object retrieve( K key );

Pointer getPointer( String key );
Pointer<V> getPointer( K key );

void free( String key );
void free( K key );

void free( Pointer pointer );
void free( Pointer<V> pointer );

void collectExpired();

Expand All @@ -68,22 +68,22 @@ public interface CacheService

long entries();

void dump( OffHeapMemoryBuffer mem );
void dump( OffHeapMemoryBuffer<V> mem );

void dump();

ConcurrentMap<String, Pointer> getMap();
ConcurrentMap<K, Pointer<V>> getMap();

void setMap( ConcurrentMap<String, Pointer> map );
void setMap( ConcurrentMap<K, Pointer<V>> map );

Serializer getSerializer();

MemoryManagerService getMemoryManager();
MemoryManagerService<V> getMemoryManager();

void setMemoryManager( MemoryManagerService memoryManager );
void setMemoryManager( MemoryManagerService<V> memoryManager );

void setSerializer( Serializer serializer );

Pointer allocate( String key, int size );
<T extends V> Pointer<V> allocate( K key, Class<T> type, int size );

}
Loading