Skip to content
Merged
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
33 changes: 14 additions & 19 deletions src/java/fr/paris/lutece/portal/service/page/PageCacheService.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ public class PageCacheService extends AbstractCacheableService<String,String>

// Performance patch
private static ConcurrentHashMap<String, String> _keyMemory = new ConcurrentHashMap<>( );
private String testCache= "init";


/**
* Init the cache. Should be called by the service at its initialization.
Expand All @@ -76,11 +74,14 @@ public class PageCacheService extends AbstractCacheableService<String,String>
public void initCache( String strCacheName )
{
Cache<String, String> cache= createCache( strCacheName, new MutableConfiguration<String,String>().setTypes(String.class, String.class) );
cache.registerCacheEntryListener(
new MutableCacheEntryListenerConfiguration<String, String>
(FactoryBuilder.factoryOf(new PageCacheEntryListener<String, String>()),null,false,false));
CacheService.registerCacheableService( this );
if ( null != cache )
{
cache.registerCacheEntryListener( new MutableCacheEntryListenerConfiguration<String, String>(
FactoryBuilder.factoryOf( new PageCacheEntryListener<String, String>( ) ), null, false, false ) );
CacheService.registerCacheableService( this );
}
}

/**
* {@inheritDoc }
*/
Expand Down Expand Up @@ -117,15 +118,8 @@ public Object clone( )
{
throw new AppException( "This class shouldn't be cloned" );
}
public String getTest() {
return testCache;
}
public void setTest(String tes) {
testCache= tes;
}


class PageCacheEntryListener<K, V> implements CacheEntryRemovedListener<K, V>, CacheEntryExpiredListener<K, V>, Serializable
static class PageCacheEntryListener<K, V> implements CacheEntryRemovedListener<K, V>, CacheEntryExpiredListener<K, V>, Serializable
{

@Override
Expand All @@ -140,13 +134,14 @@ public void onExpired(Iterable<CacheEntryEvent<? extends K, ? extends V>> events
@Override
public void onRemoved(Iterable<CacheEntryEvent<? extends K, ? extends V>> events)
throws CacheEntryListenerException {
for (CacheEntryEvent<? extends K, ? extends V> event : events)
{
_keyMemory.remove( (String) event.getKey( ) );
}
}
for ( CacheEntryEvent<? extends K, ? extends V> event : events )
{
_keyMemory.remove( (String) event.getKey( ) );
}
}

}

/**
* This method observes the initialization of the {@link ApplicationScoped} context.
* It ensures that this CDI beans are instantiated at the application startup.
Expand Down