You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2019/04/08 20:25:40 UTC

[directory-server] branch caffeine created (now f9c25f9)

This is an automated email from the ASF dual-hosted git repository.

seelmann pushed a change to branch caffeine
in repository https://gitbox.apache.org/repos/asf/directory-server.git.


      at f9c25f9  Replace ehcache with caffeine

This branch includes the following new commits:

     new f9c25f9  Replace ehcache with caffeine

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[directory-server] 01/01: Replace ehcache with caffeine

Posted by se...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

seelmann pushed a commit to branch caffeine
in repository https://gitbox.apache.org/repos/asf/directory-server.git

commit f9c25f9c082007364d3a73475b192ee661425ea8
Author: Stefan Seelmann <ma...@stefan-seelmann.de>
AuthorDate: Mon Apr 8 19:05:02 2019 +0200

    Replace ehcache with caffeine
---
 .../server/core/factory/DSAnnotationProcessor.java |   3 -
 .../factory/DefaultDirectoryServiceFactory.java    |   6 -
 core-api/pom.xml                                   |  18 +-
 .../directory/server/core/api/CacheService.java    | 219 -----------------
 .../server/core/api/DirectoryService.java          |  14 --
 .../core/api/partition/AbstractPartition.java      |  14 --
 .../server/core/api/partition/Partition.java       |   8 -
 .../server/core/api/schema/SchemaPartition.java    |   9 -
 .../src/main/resources/directory-cacheservice.xml  | 268 ---------------------
 .../server/core/api/MockDirectoryService.java      |  15 --
 core-shared/pom.xml                                |   7 +-
 .../server/core/shared/DefaultDnFactory.java       |  14 +-
 .../shared/partition/DefaultPartitionNexus.java    |   1 -
 .../server/core/DefaultDirectoryService.java       |  38 +--
 interceptors/authz/pom.xml                         |   5 -
 .../directory/server/core/authz/GroupCache.java    |  55 ++---
 interceptors/subtree/pom.xml                       |   7 +-
 .../server/core/subtree/SubtreeEvaluatorTest.java  |  13 +-
 jdbm-partition/pom.xml                             |   2 +-
 .../partition/impl/btree/jdbm/JdbmPartition.java   |  26 +-
 .../partition/impl/btree/jdbm/JdbmStoreTest.java   |   9 +-
 .../core/partition/tree/PartitionTreeTest.java     |   6 +-
 kerberos-codec/pom.xml                             |   6 +-
 .../kerberos/shared/replay/ReplayCacheImpl.java    |  38 +--
 .../shared/replay/ReplayCacheImplTest.java         | 100 ++++----
 .../core/partition/ldif/LdifPartitionTest.java     |   8 +-
 ...SingleFileLdifPartitionSingeValueAttribute.java |   9 +-
 .../ldif/SingleFileLdifPartitionTest.java          |   9 +-
 mavibot-partition/pom.xml                          |   2 +-
 .../impl/btree/mavibot/MavibotPartition.java       |  19 +-
 .../impl/btree/mavibot/MavibotStoreTest.java       |   9 +-
 .../osgi/integ/ServerCoreAnnotationsOsgiTest.java  |   1 +
 .../server/osgi/integ/ServerCoreApiOsgiTest.java   |   2 -
 .../osgi/integ/ServerCoreSharedOsgiTest.java       |   9 +-
 .../osgi/integ/ServerJdbmPartitionOsgiTest.java    |   2 +-
 .../osgi/integ/ServerMavibotPartitionOsgiTest.java |   2 +-
 pom.xml                                            |  19 +-
 .../server/changepw/ChangePasswordServer.java      |   2 -
 protocol-kerberos/pom.xml                          |   6 +-
 .../kerberos/changepwd/ChangePasswordServer.java   |   5 +-
 .../directory/server/kerberos/kdc/KdcServer.java   |   5 +-
 .../server/config/ConfigPartitionInitializer.java  |   7 +-
 .../config/ChangePasswordConfigReaderTest.java     |   8 +-
 .../server/config/ConfigPartitionReaderTest.java   |   8 +-
 .../directory/server/config/ConfigWriterTest.java  |   8 +-
 .../server/config/HttpServerConfigReaderTest.java  |   8 +-
 .../config/KerberosServerConfigReaderTest.java     |   8 +-
 .../server/config/LdapServerConfigReaderTest.java  |   8 +-
 .../server/replication/ClientInitialRefreshIT.java |   2 +-
 .../apache/directory/server/ApacheDsService.java   |  36 +--
 xdbm-partition/pom.xml                             |   3 +-
 .../impl/btree/AbstractBTreePartition.java         |  49 ++--
 .../org/apache/directory/server/xdbm/Store.java    |   4 +-
 .../search/evaluator/SubtreeScopeEvaluator.java    |   2 +-
 .../xdbm/search/impl/DefaultSearchEngine.java      |   2 +-
 .../directory/server/xdbm/PartitionTest.java       |   6 -
 .../server/xdbm/impl/avl/AvlPartitionTest.java     |   8 +-
 .../server/xdbm/search/impl/AndCursorTest.java     |   6 -
 .../server/xdbm/search/impl/EqualityTest.java      |   8 +-
 .../xdbm/search/impl/GreaterEqNotIndexedTest.java  |   8 +-
 .../server/xdbm/search/impl/GreaterEqTest.java     |   9 +-
 .../server/xdbm/search/impl/LessEqTest.java        |   9 +-
 .../server/xdbm/search/impl/NestedFilterTest.java  |   5 -
 .../server/xdbm/search/impl/NotCursorTest.java     |   5 -
 .../server/xdbm/search/impl/OrCursorTest.java      |   5 -
 .../server/xdbm/search/impl/PresenceTest.java      |  12 +-
 .../server/xdbm/search/impl/SubstringTest.java     |   9 +-
 67 files changed, 219 insertions(+), 1034 deletions(-)

diff --git a/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java b/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
index 275ac30..7d22462 100644
--- a/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
+++ b/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
@@ -235,8 +235,6 @@ public final class DSAnnotationProcessor
                     createPartition.cacheSize(),
                     new File( service.getInstanceLayout().getPartitionsDirectory(), createPartition.name() ) );
 
-                partition.setCacheService( service.getCacheService() );
-
                 CreateIndex[] indexes = createPartition.indexes();
 
                 for ( CreateIndex createIndex : indexes )
@@ -261,7 +259,6 @@ public final class DSAnnotationProcessor
                 if ( partition instanceof AbstractBTreePartition )
                 {
                     AbstractBTreePartition btreePartition = ( AbstractBTreePartition ) partition;
-                    btreePartition.setCacheService( service.getCacheService() );
                     btreePartition.setCacheSize( createPartition.cacheSize() );
                     btreePartition.setPartitionPath( new File( service
                         .getInstanceLayout().getPartitionsDirectory(),
diff --git a/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java b/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java
index 8898416..57347e9 100644
--- a/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java
+++ b/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java
@@ -37,7 +37,6 @@ import org.apache.directory.api.util.FileUtils;
 import org.apache.directory.api.util.exception.Exceptions;
 import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.core.DefaultDirectoryService;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.DirectoryService;
 import org.apache.directory.server.core.api.InstanceLayout;
 import org.apache.directory.server.core.api.partition.Partition;
@@ -247,11 +246,6 @@ public class DefaultDirectoryServiceFactory implements DirectoryServiceFactory
         directoryService.setInstanceId( name );
         buildInstanceDirectory( name );
 
-        CacheService cacheService = new CacheService();
-        cacheService.initialize( directoryService.getInstanceLayout(), name );
-
-        directoryService.setCacheService( cacheService );
-
         // Init the service now
         initSchema();
         initSystemPartition();
diff --git a/core-api/pom.xml b/core-api/pom.xml
index 8fe0cdd..f42c4b0 100644
--- a/core-api/pom.xml
+++ b/core-api/pom.xml
@@ -101,15 +101,15 @@
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-lang3</artifactId>
     </dependency>
-  
+
     <dependency>
       <groupId>org.apache.mina</groupId>
       <artifactId>mina-core</artifactId>
     </dependency>
-    
+
     <dependency>
-      <groupId>org.ehcache</groupId>
-      <artifactId>ehcache</artifactId>
+      <groupId>com.github.ben-manes.caffeine</groupId>
+      <artifactId>caffeine</artifactId>
     </dependency>
   </dependencies>
 
@@ -156,12 +156,6 @@
           <instructions>
             <Bundle-SymbolicName>${project.groupId}.core.api</Bundle-SymbolicName>
             <Export-Package>
-                org.ehcache;version=${ehcache.version},
-                org.ehcache.config;version=${ehcache.version},
-                org.ehcache.config.builders;version=${ehcache.version},
-                org.ehcache.xml;version=${ehcache.version},
-                org.ehcache.xml.model;version=${ehcache.version},
-                org.ehcache.xml.exceptions;version=${ehcache.version},
                 org.apache.directory.server.core.api;version=${project.version},
                 org.apache.directory.server.core.api.administrative;version=${project.version},
                 org.apache.directory.server.core.api.authn.ppolicy;version=${project.version},
@@ -180,10 +174,8 @@
                 org.apache.directory.server.core.api.sp.java;version=${project.version},
                 org.apache.directory.server.core.api.subtree;version=${project.version}
             </Export-Package>
-            <Require-Bundle>
-                org.ehcache.ehcache;bundle-version=${ehcache.version}
-            </Require-Bundle>
             <Import-Package>
+                com.github.benmanes.caffeine.cache;bundle-version=${caffeine.version},
                 org.apache.commons.lang3;version=${commons.lang.version},
                 org.apache.directory.api.asn1.util;version=${org.apache.directory.api.version},
                 org.apache.directory.api.i18n;version=${org.apache.directory.api.version},
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/CacheService.java b/core-api/src/main/java/org/apache/directory/server/core/api/CacheService.java
deleted file mode 100644
index 46d653e..0000000
--- a/core-api/src/main/java/org/apache/directory/server/core/api/CacheService.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- *   Licensed to the Apache Software Foundation (ASF) under one
- *   or more contributor license agreements.  See the NOTICE file
- *   distributed with this work for additional information
- *   regarding copyright ownership.  The ASF licenses this file
- *   to you under the Apache License, Version 2.0 (the
- *   "License"); you may not use this file except in compliance
- *   with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *   Unless required by applicable law or agreed to in writing,
- *   software distributed under the License is distributed on an
- *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *   KIND, either express or implied.  See the License for the
- *   specific language governing permissions and limitations
- *   under the License.
- *
- */
-
-package org.apache.directory.server.core.api;
-
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.util.Iterator;
-
-import org.ehcache.Cache;
-import org.ehcache.Cache.Entry;
-import org.ehcache.CacheManager;
-import org.ehcache.Status;
-import org.ehcache.config.builders.CacheManagerBuilder;
-import org.ehcache.xml.XmlConfiguration;
-import org.ehcache.xml.exceptions.XmlConfigurationException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * A ehcache based cache service to be used for various caching requirement in the server. 
- * 
- * If a cache config file with the name {@link #DIRECTORY_CACHESERVICE_XML} is present in
- * the "workdirectory" of the DirectoryService then that file will be used for configuring 
- * the {@link CacheManager}, if not a default cache configuration file bundled along with 
- * this class is used
- *
- * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- */
-public class CacheService
-{
-    /** The cache configuration file */
-    private static final String DIRECTORY_CACHESERVICE_XML = "directory-cacheservice.xml";
-
-    /** The associated logger */
-    private static final Logger LOG = LoggerFactory.getLogger( CacheService.class );
-
-    /** the ehcache cache manager */
-    private CacheManager cacheManager = null;
-
-    /**
-     * Utility method to dump the cache contents to a StringBuffer.
-     * This is needed because ehcache 3.x Cache objects only implements Iterable
-     * 
-     * @return a StringBuffer
-     */
-    public static final StringBuffer dumpCacheContentsToString( Cache< ?, ? > cache ) 
-    {
-        Iterator<?> it = cache.iterator();
-        StringBuffer sb = new StringBuffer();
-        
-        while ( it.hasNext() )
-        {
-            Cache.Entry< ?, ? > nextObj = ( Entry<?, ?> ) it.next();
-            sb.append( '\t' )
-            .append( nextObj.getKey().toString() )
-            .append( " -> " )
-            .append( nextObj.getValue().toString() )
-            .append( '\n' );
-        }
-        
-        return sb;
-    }
-
-    /**
-     * Creates a new instance of CacheService.
-     */
-    public CacheService()
-    {
-    }
-
-
-    /**
-     * Creates a new instance of CacheService with the given cache manager.
-     *
-     * @param cachemanager The provided CaxcheManager instance
-     */
-    public CacheService( CacheManager cachemanager )
-    {
-        this.cacheManager = cachemanager;
-    }
-
-
-    /**
-     * Initialize the CacheService
-     *
-     * @param layout The place on disk where the cache configuration will be stored
-     */
-    public void initialize( InstanceLayout layout )
-    {
-        initialize( layout, null );
-    }
-
-
-    /**
-     * Initialize the CacheService
-     *
-     * @param layout The place on disk where the cache configuration will be stored
-     * @param instanceId The Instance identifier
-     */
-    public void initialize( InstanceLayout layout, String instanceId )
-    {
-        LOG.debug( "CacheService initialization, for instance {}", instanceId );
-
-        if ( ( cacheManager != null ) && ( cacheManager.getStatus() == Status.AVAILABLE ) )
-        {
-            LOG.warn( "cache service was already initialized and is available" );
-
-            return;
-        }
-
-        XmlConfiguration cc = null;
-
-        if ( layout != null )
-        {
-            File configFile = new File( layout.getConfDirectory(), DIRECTORY_CACHESERVICE_XML );
-
-            if ( !configFile.exists() )
-            {
-                LOG.info( "no custom cache configuration was set, loading the default cache configuration" );
-                cc = new XmlConfiguration( getClass().getClassLoader().getResource(
-                    DIRECTORY_CACHESERVICE_XML ), getClass().getClassLoader() );
-            }
-            else
-            {
-                LOG.info( "loading cache configuration from the file {}", configFile );
-                
-                try
-                {
-                    cc = new XmlConfiguration( configFile.toURI().toURL(), getClass().getClassLoader() );
-                }
-                catch ( XmlConfigurationException | MalformedURLException e ) 
-                {
-                    LOG.error( "exception loading cache configuration from the file {}: {}", configFile, e.toString() );
-                }
-            }
-        }
-        else
-        {
-            LOG.info( "no custom cache configuration was set, loading the default cache configuration" );
-            cc = new XmlConfiguration( getClass().getClassLoader().getResource(
-                DIRECTORY_CACHESERVICE_XML ), getClass().getClassLoader() );
-        }
-
-        cacheManager = CacheManagerBuilder.newCacheManager( cc );
-        cacheManager.init();
-    }
-
-
-    /**
-     * Clear the cache and shutdown it
-     */
-    public void destroy()
-    {
-        if ( cacheManager == null )
-        {
-            return;
-        }
-
-        LOG.info( "clearing all the caches" );
-
-        cacheManager.close();
-        cacheManager = null;
-    }
-
-
-    /**
-     * Get a specific cache from its name, or create a new one
-     *
-     * @param name The Cache name we want to retreive
-     * @return The found cache. If we don't find it, we create a new one.
-     */
-    public <K, V> Cache<K, V> getCache( String name, Class<K> keyClazz, Class<V> valueClazz )
-    {
-        if ( cacheManager == null )
-        {
-            LOG.error( "Cannot fetch the cache named {}, the CacheServcie is not initialized", name );
-            throw new IllegalStateException( "CacheService was not initialized" );
-        }
-
-        LOG.info( "fetching the cache named {}", name );
-
-        Cache<K, V> cache = cacheManager.getCache( name, keyClazz, valueClazz );
-        
-        return cache;
-    }
-
-
-    /**
-     * Remove a cache if it exists.
-     * 
-     * @param name The Cache's name we want to remove
-     */
-    public void remove( String name )
-    {
-        LOG.info( "Removing the cache named {}", name );
-        
-        cacheManager.removeCache( name );
-    }
-}
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/DirectoryService.java b/core-api/src/main/java/org/apache/directory/server/core/api/DirectoryService.java
index e7eafd9..a0b6d76 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/DirectoryService.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/DirectoryService.java
@@ -579,12 +579,6 @@ public interface DirectoryService extends ServerEntryFactory
 
 
     /**
-     * @return the cache service
-     */
-    CacheService getCacheService();
-
-
-    /**
      * @return The AccessControl AdministrativePoint cache
      */
     DnNode<AccessControlAdministrativePoint> getAccessControlAPCache();
@@ -631,14 +625,6 @@ public interface DirectoryService extends ServerEntryFactory
 
 
     /**
-     * Sets the CacheService
-     * 
-     * @param cacheService the cache service
-     */
-    void setCacheService( CacheService cacheService );
-
-
-    /**
      * Gets the {@link AttributeTypeProvider}.
      * 
      * @return the {@link AttributeTypeProvider}
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/partition/AbstractPartition.java b/core-api/src/main/java/org/apache/directory/server/core/api/partition/AbstractPartition.java
index b680510..d6f1aed 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/partition/AbstractPartition.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/partition/AbstractPartition.java
@@ -32,7 +32,6 @@ import org.apache.directory.api.ldap.model.exception.LdapOtherException;
 import org.apache.directory.api.ldap.model.name.Dn;
 import org.apache.directory.api.ldap.model.schema.SchemaManager;
 import org.apache.directory.api.util.Strings;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.DnFactory;
 import org.apache.directory.server.i18n.I18n;
 
@@ -64,9 +63,6 @@ public abstract class AbstractPartition implements Partition
     /** The root Dn for this partition */
     protected Dn suffixDn;
 
-    /** the cache service */
-    protected CacheService cacheService;
-
     /** the value of last successful add/update operation's CSN */
     private String contextCsn;
     
@@ -292,16 +288,6 @@ public abstract class AbstractPartition implements Partition
      * {@inheritDoc}
      */
     @Override
-    public void setCacheService( CacheService cacheService )
-    {
-        this.cacheService = cacheService;
-    }
-
-    
-    /**
-     * {@inheritDoc}
-     */
-    @Override
     public String getContextCsn( PartitionTxn partitionTxn )
     {
         return contextCsn;
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/partition/Partition.java b/core-api/src/main/java/org/apache/directory/server/core/api/partition/Partition.java
index bb3fccd..3f3164c 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/partition/Partition.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/partition/Partition.java
@@ -29,7 +29,6 @@ import org.apache.directory.api.ldap.model.exception.LdapException;
 import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.api.ldap.model.name.Dn;
 import org.apache.directory.api.ldap.model.schema.SchemaManager;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.api.interceptor.context.AddOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.DeleteOperationContext;
@@ -309,13 +308,6 @@ public interface Partition
     void dumpIndex( PartitionTxn partitionTxn, OutputStream stream, String name ) throws IOException;
 
 
-    /**
-     * Set the Cache service 
-     *
-     * @param cacheService The CacheService instance
-     */
-    void setCacheService( CacheService cacheService );
-
     
     /**
      * Get the contextCSN
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/schema/SchemaPartition.java b/core-api/src/main/java/org/apache/directory/server/core/api/schema/SchemaPartition.java
index a0cf514..4d127b4 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/schema/SchemaPartition.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/schema/SchemaPartition.java
@@ -44,7 +44,6 @@ import org.apache.directory.api.ldap.model.schema.SchemaManager;
 import org.apache.directory.api.ldap.model.schema.SchemaUtils;
 import org.apache.directory.api.util.DateUtils;
 import org.apache.directory.server.constants.ApacheSchemaConstants;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.CoreSession;
 import org.apache.directory.server.core.api.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.api.interceptor.context.AddOperationContext;
@@ -556,14 +555,6 @@ public final class SchemaPartition extends AbstractPartition
     }
 
 
-    @Override
-    public void setCacheService( CacheService cacheService )
-    {
-        super.setCacheService( cacheService );
-        wrapped.setCacheService( cacheService );
-    }
-
-
     /**
      * @see Object#toString()
      */
diff --git a/core-api/src/main/resources/directory-cacheservice.xml b/core-api/src/main/resources/directory-cacheservice.xml
deleted file mode 100644
index f173899..0000000
--- a/core-api/src/main/resources/directory-cacheservice.xml
+++ /dev/null
@@ -1,268 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-  
-  http://www.apache.org/licenses/LICENSE-2.0
-  
-  Unless required by applicable law or agreed to in writing,
-  software distributed under the License is distributed on an
-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  KIND, either express or implied.  See the License for the
-  specific language governing permissions and limitations
-  under the License.
--->
-<config xmlns="http://www.ehcache.org/v3"
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core-3.6.xsd">
-	
-	<!--
-		Cache configuration
-		===================
-		
-		The following attributes are required.
-		
-		name:
-			Sets the name of the cache. This is used to identify the cache. It must be unique.
-		
-		maxElementsInMemory:
-			Sets the maximum number of objects that will be created in memory
-		
-		maxElementsOnDisk:
-			Sets the maximum number of objects that will be maintained in the DiskStore
-			The default value is zero, meaning unlimited.
-		
-		eternal:
-			Sets whether elements are eternal. If eternal,  timeouts are ignored and the
-			element is never expired.
-		
-		overflowToDisk:
-			Sets whether elements can overflow to disk when the memory store
-			has reached the maxInMemory limit.
-		
-		The following attributes and elements are optional.
-		
-		timeToIdleSeconds:
-			Sets the time to idle for an element before it expires.
-			i.e. The maximum amount of time between accesses before an element expires
-			Is only used if the element is not eternal.
-			Optional attribute. A value of 0 means that an Element can idle for infinity.
-			The default value is 0.
-		
-		timeToLiveSeconds:
-			Sets the time to live for an element before it expires.
-			i.e. The maximum time between creation time and when an element expires.
-			Is only used if the element is not eternal.
-			Optional attribute. A value of 0 means that and Element can live for infinity.
-			The default value is 0.
-		
-		diskPersistent:
-			Whether the disk store persists between restarts of the Virtual Machine.
-			The default value is false.
-		
-		diskExpiryThreadIntervalSeconds:
-			The number of seconds between runs of the disk expiry thread. The default value
-			is 120 seconds.
-		
-		diskSpoolBufferSizeMB:
-			This is the size to allocate the DiskStore for a spool buffer. Writes are made
-			to this area and then asynchronously written to disk. The default size is 30MB.
-			Each spool buffer is used only by its cache. If you get OutOfMemory errors consider
-			lowering this value. To improve DiskStore performance consider increasing it. Trace level
-			logging in the DiskStore will show if put back ups are occurring.
-		
-		clearOnFlush:
-			whether the MemoryStore should be cleared when flush() is called on the cache.
-			By default, this is true i.e. the MemoryStore is cleared.
-		
-		memoryStoreEvictionPolicy:
-			Policy would be enforced upon reaching the maxElementsInMemory limit. Default
-			policy is Least Recently Used (specified as LRU). Other policies available -
-			First In First Out (specified as FIFO) and Less Frequently Used
-			(specified as LFU)
-	-->
-
-	<!-- Sample cache named sampleCache1 This cache contains a maximum in memory 
-		of 10000 elements, and will expire an element if it is idle for more than 
-		5 minutes and lives for more than 10 minutes. If there are more than 10000 
-		elements it will overflow to the disk cache, which in this configuration 
-		will go to wherever java.io.tmp is defined on your system. On a standard 
-		Linux system this will be /tmp" -->
-	<!-- 
-		Note: set the 'overflowToDisk' flag always to 'true'.
-		The groups information is only read once during startup hence 
-		we need to retain this info forever available in the cache
-		as long as the server is running, so hinting the cache to store
-		on disk is needed to swap the data if it is too much to hold in memory -->
-	<cache alias="groupCache">
-		<key-type>java.lang.String</key-type>
-		<value-type>java.util.Set</value-type>
-		<expiry>
-			<ttl unit="seconds">1200</ttl>
-		</expiry>
-		<heap>10000</heap>
-		<heap-store-settings>
-			<max-object-size>10000</max-object-size>
-		</heap-store-settings>
-
-		<!-- unmigrated 2.x settings		   
-			eternal="true" 
-			overflowToDisk="true"
-			diskSpoolBufferSizeMB="20"
-			memoryStoreEvictionPolicy="LFU"
-			diskPersistent="false" />
-		-->
-	</cache>
-
-	<cache alias="dnCache">
-		<key-type>java.lang.String</key-type>
-		<value-type>org.apache.directory.api.ldap.model.name.Dn</value-type>
-		<expiry>
-			<ttl unit="seconds">600</ttl>
-		</expiry>
-		<heap>10000</heap>
-		<heap-store-settings>
-			<max-object-size>10000</max-object-size>
-		</heap-store-settings>
-		<!-- unmigrated 2.x settings
-		   eternal="false" 
-		   overflowToDisk="false"
-		   diskSpoolBufferSizeMB="20"
-		   timeToIdleSeconds="300"
-		   timeToLiveSeconds="600"
-		   memoryStoreEvictionPolicy="LFU" 
-		   diskPersistent="false" /> 
-		-->
-	</cache>
-	
-
-	<!-- Kerberos replay cache
-		NOTE1: keep the maxElementsInMemory as low as possible to avoid wasting memory
-		Cause the elements present in the cache won't be removed dynamically even after their TTL
-		expires. For a good explanation see http://forums.terracotta.org/forums/posts/list/4126.page
-		
-		NOTE2: We don't use the standard eviction policies like LFU or LRU rather we use a custom eviction
-			policy based on the value of clockskew setting. The default value of clokcskew is 5 minutes,
-			which is also set for the TTL and TTI values of cache config
-			
-		So what we do here is enable the overflowToDisk flag and then let the disk store be cleaned
-		periodically based on diskExpiryThreadIntervalSeconds
-	-->
-	<cache alias="kdcReplayCache">
-		<key-type>java.lang.String</key-type>
-		<expiry>
-			<ttl unit="seconds">600</ttl>
-		</expiry>
-		<heap>100</heap>
-		<heap-store-settings>
-			<max-object-size>100</max-object-size>
-		</heap-store-settings>
-
-		<!-- unmigrated 2.x settings
-		   eternal="false" 
-		   overflowToDisk="true"
-		   diskSpoolBufferSizeMB="20"
-		   diskExpiryThreadIntervalSeconds="300"
-		   timeToLiveSeconds="300"
-		   timeToIdleSeconds="300"
-		   diskPersistent="false" />
-		-->
-	</cache>
-
-	<!-- ChangePassword replay cache, this has the same settings as the Kerberos replay cache -->
-	<cache alias="changePwdReplayCache">
-		<key-type>java.lang.String</key-type>
-		<expiry>
-			<ttl unit="seconds">600</ttl>
-		</expiry>
-		<heap>100</heap>
-		<heap-store-settings>
-			<max-object-size>100</max-object-size>
-		</heap-store-settings>
-
-		<!-- unmigrated 2.x settings
-		   eternal="false" 
-		   overflowToDisk="true"
-		   diskSpoolBufferSizeMB="20"
-		   diskExpiryThreadIntervalSeconds="300"
-		   timeToLiveSeconds="300"
-		   timeToIdleSeconds="300"
-		   diskPersistent="false" />
-		-->
-	</cache>
-
-	<!-- partition caches
-		the name format:
-		name="{partition-suffix}" for partition
-		name="{partition-suffix}:{index name/OID}" for each partition's index (currently only RDN index supports cache)
-	-->
-	<cache alias="ou=system">
-		<key-type>java.lang.String</key-type>
-		<expiry>
-			<ttl unit="seconds">600</ttl>
-		</expiry>
-		<heap>1000</heap>
-		<heap-store-settings>
-			<max-object-size>1000</max-object-size>
-		</heap-store-settings>
-		
-		<!-- unmigrated 2.x settings
-		   eternal="false" 
-		   overflowToDisk="true"
-		   diskSpoolBufferSizeMB="20"
-		   timeToIdleSeconds="300"
-		   timeToLiveSeconds="600"
-		   memoryStoreEvictionPolicy="LFU"
-		   diskPersistent="false"/>
-		-->
-	</cache>
-	
-	<cache alias="ou=system:apacheRdn">
-		<key-type>java.lang.String</key-type>
-		<expiry>
-			<ttl unit="seconds">600</ttl>
-		</expiry>
-		<heap>10000</heap>
-		<heap-store-settings>
-			<max-object-size>10000</max-object-size>
-		</heap-store-settings>
-		
-		<!-- unmigrated 2.x settings
-		   eternal="false" 
-		   overflowToDisk="false"
-		   timeToIdleSeconds="300"
-		   timeToLiveSeconds="600"
-		   memoryStoreEvictionPolicy="LFU"
-		   diskPersistent="false"/>
-		-->
-	</cache>
- 
-	<cache alias="alias">
-		<key-type>java.lang.String</key-type>
-		<value-type>org.apache.directory.api.ldap.model.name.Dn</value-type>
-		<expiry>
-			<ttl unit="seconds">1200</ttl>
-		</expiry>
-		<heap>1000</heap>
-		<heap-store-settings>
-			<max-object-size>1000</max-object-size>
-		</heap-store-settings>
-	</cache>
-
-	<cache alias="entryDn">
-		<key-type>java.lang.String</key-type>
-		<value-type>org.apache.directory.api.ldap.model.name.Dn</value-type>
-		<expiry>
-			<ttl unit="seconds">1200</ttl>
-		</expiry>
-		<heap>1000</heap>
-		<heap-store-settings>
-			<max-object-size>1000</max-object-size>
-		</heap-store-settings>
-	</cache>
-</config>
\ No newline at end of file
diff --git a/core-api/src/test/java/org/apache/directory/server/core/api/MockDirectoryService.java b/core-api/src/test/java/org/apache/directory/server/core/api/MockDirectoryService.java
index 12b41a3..65041ef 100644
--- a/core-api/src/test/java/org/apache/directory/server/core/api/MockDirectoryService.java
+++ b/core-api/src/test/java/org/apache/directory/server/core/api/MockDirectoryService.java
@@ -476,12 +476,6 @@ public class MockDirectoryService implements DirectoryService
     }
 
 
-    public CacheService getCacheService()
-    {
-        return null;
-    }
-
-
     /**
      * {@inheritDoc}
      */
@@ -614,15 +608,6 @@ public class MockDirectoryService implements DirectoryService
     }
 
 
-    /**
-     * {@inheritDoc}
-     */
-    public void setCacheService( CacheService cacheService )
-    {
-        // nothing
-    }
-
-
     @Override
     public AttributeTypeProvider getAtProvider()
     {
diff --git a/core-shared/pom.xml b/core-shared/pom.xml
index 7d1ca28..0c07a67 100644
--- a/core-shared/pom.xml
+++ b/core-shared/pom.xml
@@ -78,11 +78,6 @@
     </dependency>
     
     <dependency>
-      <groupId>org.ehcache</groupId>
-      <artifactId>ehcache</artifactId>
-    </dependency>
-
-    <dependency>
        <groupId>org.apache.directory.jdbm</groupId>
        <artifactId>apacheds-jdbm1</artifactId>
     </dependency>
@@ -147,7 +142,7 @@
                 jdbm.btree,
                 jdbm.helper,
                 jdbm.recman,
-                org.ehcache;version=${ehcache.version},
+                com.github.benmanes.caffeine.cache;bundle-version=${caffeine.version},
                 org.apache.directory.api.ldap.codec.api;version=${org.apache.directory.api.version},
                 org.apache.directory.api.ldap.extras.controls.syncrepl.syncDone;version=${org.apache.directory.api.version},
                 org.apache.directory.api.ldap.extras.controls.syncrepl.syncState;version=${org.apache.directory.api.version},
diff --git a/core-shared/src/main/java/org/apache/directory/server/core/shared/DefaultDnFactory.java b/core-shared/src/main/java/org/apache/directory/server/core/shared/DefaultDnFactory.java
index af896fd..4cffdf5 100644
--- a/core-shared/src/main/java/org/apache/directory/server/core/shared/DefaultDnFactory.java
+++ b/core-shared/src/main/java/org/apache/directory/server/core/shared/DefaultDnFactory.java
@@ -21,7 +21,7 @@
 package org.apache.directory.server.core.shared;
 
 
-import org.ehcache.Cache;
+import java.time.Duration;
 
 import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.api.ldap.model.name.Dn;
@@ -30,6 +30,9 @@ import org.apache.directory.server.core.api.DnFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
+
 
 /**
  * The default Dn factory implementation.
@@ -58,12 +61,13 @@ public class DefaultDnFactory implements DnFactory
      * Instantiates a new default Dn factory.
      *
      * @param schemaManager The SchemaManager instance
-     * @param dnCache The cache used to store DNs
+     * @param cacheSize The cache size used to store DNs
      */
-    public DefaultDnFactory( SchemaManager schemaManager, Cache<String, Dn> dnCache )
+    public DefaultDnFactory( SchemaManager schemaManager, int cacheSize )
     {
         this.schemaManager = schemaManager;
-        this.dnCache = dnCache;
+        this.dnCache = Caffeine.newBuilder().maximumSize( cacheSize ).expireAfterAccess( Duration.ofMinutes( 10L ) )
+            .build();
     }
 
 
@@ -89,7 +93,7 @@ public class DefaultDnFactory implements DnFactory
         // for the reason for performing this check
         if ( dnCache != null )
         {
-            cachedDn = dnCache.get( dn );
+            cachedDn = dnCache.getIfPresent( dn );
         }
 
         if ( cachedDn == null )
diff --git a/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultPartitionNexus.java b/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultPartitionNexus.java
index 5466b0a..2503628 100644
--- a/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultPartitionNexus.java
+++ b/core-shared/src/main/java/org/apache/directory/server/core/shared/partition/DefaultPartitionNexus.java
@@ -828,7 +828,6 @@ public class DefaultPartitionNexus extends AbstractPartition implements Partitio
 
         if ( !partition.isInitialized() )
         {
-            partition.setCacheService( directoryService.getCacheService() );
             partition.initialize();
         }
 
diff --git a/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java b/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
index a8a965f..50a5edc 100644
--- a/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
+++ b/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
@@ -72,7 +72,6 @@ import org.apache.directory.server.constants.ApacheSchemaConstants;
 import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.core.admin.AdministrativePointInterceptor;
 import org.apache.directory.server.core.api.AttributeTypeProvider;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.CoreSession;
 import org.apache.directory.server.core.api.DirectoryService;
 import org.apache.directory.server.core.api.DnFactory;
@@ -267,9 +266,6 @@ public class DefaultDirectoryService implements DirectoryService
 
     private static final String LOCK_FILE_NAME = ".dirservice.lock";
 
-    /** the ehcache based cache service */
-    private CacheService cacheService;
-
     /** The AccessControl AdministrativePoint cache */
     private DnNode<AccessControlAdministrativePoint> accessControlAPCache;
 
@@ -1306,9 +1302,6 @@ public class DefaultDirectoryService implements DirectoryService
         // --------------------------------------------------------------------
         // And shutdown the server
         // --------------------------------------------------------------------
-        LOG.debug( "--- Deleting the cache service" );
-        cacheService.destroy();
-
         LOG.debug( "---Deleting the DnCache" );
         dnFactory = null;
 
@@ -1947,14 +1940,6 @@ public class DefaultDirectoryService implements DirectoryService
             setDefaultInterceptorConfigurations();
         }
 
-        if ( cacheService == null )
-        {
-            // Initialize a default cache service
-            cacheService = new CacheService();
-        }
-
-        cacheService.initialize( instanceLayout, instanceId );
-
         // Initialize the AP caches
         accessControlAPCache = new DnNode<>();
         collectiveAttributeAPCache = new DnNode<>();
@@ -1963,15 +1948,12 @@ public class DefaultDirectoryService implements DirectoryService
 
         if ( dnFactory == null )
         {
-            dnFactory = new DefaultDnFactory( schemaManager, 
-                cacheService.getCache( "dnCache", String.class, Dn.class ) );
+            dnFactory = new DefaultDnFactory( schemaManager, 10000 );
         }
 
         // triggers partition to load schema fully from schema partition
-        schemaPartition.setCacheService( cacheService );
         schemaPartition.initialize();
         partitions.add( schemaPartition );
-        systemPartition.setCacheService( cacheService );
         
         if ( !systemPartition.getSuffixDn().isSchemaAware() )
         {
@@ -2368,15 +2350,6 @@ public class DefaultDirectoryService implements DirectoryService
     /**
      * {@inheritDoc}
      */
-    public CacheService getCacheService()
-    {
-        return cacheService;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
     public DnNode<AccessControlAdministrativePoint> getAccessControlAPCache()
     {
         return accessControlAPCache;
@@ -2470,15 +2443,6 @@ public class DefaultDirectoryService implements DirectoryService
     /**
      * {@inheritDoc}
      */
-    public void setCacheService( CacheService cacheService )
-    {
-        this.cacheService = cacheService;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public AttributeTypeProvider getAtProvider()
     {
diff --git a/interceptors/authz/pom.xml b/interceptors/authz/pom.xml
index 48fd893..b0f0b8e 100644
--- a/interceptors/authz/pom.xml
+++ b/interceptors/authz/pom.xml
@@ -72,10 +72,6 @@
       <artifactId>api-ldap-schema-data</artifactId>
     </dependency>
     
-    <dependency>
-      <groupId>org.ehcache</groupId>
-      <artifactId>ehcache</artifactId>
-    </dependency>
   </dependencies>
 
   <build>
@@ -130,7 +126,6 @@
             </Export-Package>
             <Import-Package>
                 javax.naming.directory,
-                org.ehcache;version=${ehcache.version},
                 org.apache.directory.api.ldap.aci;version=${org.apache.directory.api.version},
                 org.apache.directory.api.ldap.aci.protectedItem;version=${org.apache.directory.api.version},
                 org.apache.directory.api.ldap.model.constants;version=${org.apache.directory.api.version},
diff --git a/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/GroupCache.java b/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/GroupCache.java
index 5dc6eef..cdf9a01 100644
--- a/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/GroupCache.java
+++ b/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/GroupCache.java
@@ -21,14 +21,13 @@ package org.apache.directory.server.core.authz;
 
 
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 
 import javax.naming.directory.SearchControls;
 
-import org.ehcache.Cache;
-
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.entry.Attribute;
 import org.apache.directory.api.ldap.model.entry.Entry;
@@ -45,7 +44,6 @@ import org.apache.directory.api.ldap.model.name.Dn;
 import org.apache.directory.api.ldap.model.schema.AttributeType;
 import org.apache.directory.api.ldap.model.schema.SchemaManager;
 import org.apache.directory.server.constants.ServerDNConstants;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.CoreSession;
 import org.apache.directory.server.core.api.DirectoryService;
 import org.apache.directory.server.core.api.DnFactory;
@@ -94,8 +92,7 @@ public class GroupCache
     private static final Set<String> EMPTY_GROUPS = new HashSet<>();
 
     /** String key for the Dn of a group to a Set (HashSet) for the Strings of member DNs */
-    private Cache< String, Set > groupCache;
-
+    private final Map<String, Set<String>> groups = new ConcurrentHashMap<>();
 
 
     /**
@@ -114,8 +111,6 @@ public class GroupCache
         // stuff for dealing with the admin group
         administratorsGroupDn = parseNormalized( ServerDNConstants.ADMINISTRATORS_GROUP_DN );
 
-        groupCache = dirService.getCacheService().getCache( "groupCache", String.class, Set.class );
-
         initialize( dirService.getAdminSession() );
     }
 
@@ -179,7 +174,7 @@ public class GroupCache
                         Set<String> memberSet = new HashSet<>( members.size() );
                         addMembers( memberSet, members );
 
-                        groupCache.put( groupDn.getNormName(), memberSet );
+                        groups.put( groupDn.getNormName(), memberSet );
                     }
                     else
                     {
@@ -200,8 +195,7 @@ public class GroupCache
 
         if ( IS_DEBUG )
         {
-            LOG.debug( "group cache contents on startup:\n {}", 
-                CacheService.dumpCacheContentsToString( groupCache ) );
+            LOG.debug( "group cache contents on startup:\n {}", groups );
         }
     }
 
@@ -314,12 +308,11 @@ public class GroupCache
         Set<String> memberSet = new HashSet<>( members.size() );
         addMembers( memberSet, members );
 
-        groupCache.put( name, memberSet );
+        groups.put( name, memberSet );
 
         if ( IS_DEBUG )
         {
-            LOG.debug( "group cache contents after adding '{}' :\n {}", name,
-                CacheService.dumpCacheContentsToString( groupCache ) );
+            LOG.debug( "group cache contents after adding '{}' :\n {}", name, groups );
         }
     }
 
@@ -341,12 +334,11 @@ public class GroupCache
             return;
         }
 
-        groupCache.remove( name.getNormName() );
+        groups.remove( name.getNormName() );
 
         if ( IS_DEBUG )
         {
-            LOG.debug( "group cache contents after deleting '{}' :\n {}", name.getName(),
-                CacheService.dumpCacheContentsToString( groupCache ) );
+            LOG.debug( "group cache contents after deleting '{}' :\n {}", name.getName(), groups );
         }
     }
 
@@ -427,7 +419,7 @@ public class GroupCache
         {
             if ( memberAttr.getOid() == modification.getAttribute().getId() )
             {
-                Set<String> memberSet = groupCache.get( name.getNormName() );
+                Set<String> memberSet = groups.get( name.getNormName() );
                 
                 if ( memberSet != null )
                 {
@@ -440,8 +432,7 @@ public class GroupCache
 
         if ( IS_DEBUG )
         {
-            LOG.debug( "group cache contents after modifying '{}' :\n {}", name.getName(),
-                CacheService.dumpCacheContentsToString( groupCache ) );
+            LOG.debug( "group cache contents after modifying '{}' :\n {}", name.getName(), groups );
         }
     }
 
@@ -464,7 +455,7 @@ public class GroupCache
             return;
         }
 
-        Set<String> memberSet = groupCache.get( name.getNormName() );
+        Set<String> memberSet = groups.get( name.getNormName() );
 
         if ( memberSet != null )
         {
@@ -473,8 +464,7 @@ public class GroupCache
 
         if ( IS_DEBUG )
         {
-            LOG.debug( "group cache contents after modifying '{}' :\n {}", name.getName(),
-                CacheService.dumpCacheContentsToString( groupCache ) );
+            LOG.debug( "group cache contents after modifying '{}' :\n {}", name.getName(), groups );
         }
     }
 
@@ -493,7 +483,7 @@ public class GroupCache
             return true;
         }
 
-        Set<String> members = groupCache.get( administratorsGroupDn.getNormName() );
+        Set<String> members = groups.get( administratorsGroupDn.getNormName() );
         
         if ( members == null )
         {
@@ -519,12 +509,10 @@ public class GroupCache
     {
         Set<String> memberGroups = null;
 
-        Iterator<Cache.Entry<String, Set>> iterator = groupCache.iterator();
-        while ( iterator.hasNext() )
+        for ( Map.Entry<String, Set<String>> entry : groups.entrySet() )
         {
-            Cache.Entry<String, Set> next = iterator.next();
-            String group = next.getKey();
-            Set<String> members = next.getValue();
+            String group = entry.getKey();
+            Set<String> members = entry.getValue();
 
             if ( members == null )
             {
@@ -553,18 +541,17 @@ public class GroupCache
 
     public boolean groupRenamed( Dn oldName, Dn newName )
     {
-        Set<String> members = groupCache.get( oldName.getNormName() );
+        Set<String> members = groups.get( oldName.getNormName() );
 
         if ( members != null )
         {
-            groupCache.remove( oldName.getNormName() );
+            groups.remove( oldName.getNormName() );
 
-            groupCache.put( newName.getNormName(), members );
+            groups.put( newName.getNormName(), members );
 
             if ( IS_DEBUG )
             {
-                LOG.debug( "group cache contents after renaming '{}' :\n{}", oldName.getName(),
-                    CacheService.dumpCacheContentsToString( groupCache ) );
+                LOG.debug( "group cache contents after renaming '{}' :\n{}", oldName.getName(), groups );
             }
 
             return true;
diff --git a/interceptors/subtree/pom.xml b/interceptors/subtree/pom.xml
index e822e71..9e09221 100644
--- a/interceptors/subtree/pom.xml
+++ b/interceptors/subtree/pom.xml
@@ -77,10 +77,6 @@
       <artifactId>api-util</artifactId>
     </dependency>
     
-    <dependency>
-      <groupId>org.ehcache</groupId>
-      <artifactId>ehcache</artifactId>
-    </dependency>
   </dependencies>
 
   <build>
@@ -134,8 +130,7 @@
             </Export-Package>
             <Import-Package>
                 javax.naming.directory,
-                org.ehcache;version=${ehcache.version},
-                org.ehcache.config.builders;version=${ehcache.version},
+                com.github.benmanes.caffeine.cache;bundle-version=${caffeine.version},
                 org.apache.directory.api.ldap.codec.controls.search.subentries;version=${org.apache.directory.api.version},
                 org.apache.directory.api.ldap.model.constants;version=${org.apache.directory.api.version},
                 org.apache.directory.api.ldap.model.entry;version=${org.apache.directory.api.version},
diff --git a/interceptors/subtree/src/test/java/org/apache/directory/server/core/subtree/SubtreeEvaluatorTest.java b/interceptors/subtree/src/test/java/org/apache/directory/server/core/subtree/SubtreeEvaluatorTest.java
index ad384f5..698f8bf 100644
--- a/interceptors/subtree/src/test/java/org/apache/directory/server/core/subtree/SubtreeEvaluatorTest.java
+++ b/interceptors/subtree/src/test/java/org/apache/directory/server/core/subtree/SubtreeEvaluatorTest.java
@@ -46,16 +46,13 @@ import org.apache.directory.server.core.api.DnFactory;
 import org.apache.directory.server.core.api.normalization.FilterNormalizingVisitor;
 import org.apache.directory.server.core.api.subtree.SubtreeEvaluator;
 import org.apache.directory.server.core.shared.DefaultDnFactory;
-import org.ehcache.Cache;
-import org.ehcache.CacheManager;
-import org.ehcache.config.builders.CacheConfigurationBuilder;
-import org.ehcache.config.builders.CacheManagerBuilder;
-import org.ehcache.config.builders.ResourcePoolsBuilder;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
 import com.mycila.junit.concurrent.Concurrency;
 import com.mycila.junit.concurrent.ConcurrentJunitRunner;
 
@@ -74,7 +71,6 @@ public class SubtreeEvaluatorTest
     private static SubtreeEvaluator evaluator;
     private static FilterNormalizingVisitor visitor;
     private static ConcreteNameComponentNormalizer ncn;
-    private static Cache<String, Dn> dnCache;
 
 
     @BeforeClass
@@ -102,9 +98,7 @@ public class SubtreeEvaluatorTest
             fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
         }
 
-        CacheManager cm = CacheManagerBuilder.newCacheManagerBuilder().withCache( "dnCache", CacheConfigurationBuilder.newCacheConfigurationBuilder( String.class, Dn.class, ResourcePoolsBuilder.heap(1000)).build()).build();
-        cm.init();
-        dnCache = cm.getCache( "dnCache", String.class, Dn.class );        dnFactory = new DefaultDnFactory( schemaManager, dnCache );
+        dnFactory = new DefaultDnFactory( schemaManager, 100 );
 
         ncn = new ConcreteNameComponentNormalizer( schemaManager );
 
@@ -118,7 +112,6 @@ public class SubtreeEvaluatorTest
     {
         visitor = null;
         evaluator = null;
-        dnCache.clear();
     }
 
 
diff --git a/jdbm-partition/pom.xml b/jdbm-partition/pom.xml
index 21c35ce..47886df 100644
--- a/jdbm-partition/pom.xml
+++ b/jdbm-partition/pom.xml
@@ -150,7 +150,7 @@
                 jdbm.btree,
                 jdbm.helper,
                 jdbm.recman,
-                org.ehcache;version=${ehcache.version},
+                com.github.benmanes.caffeine.cache;bundle-version=${caffeine.version},
                 org.apache.directory.api.ldap.model.constants;version=${org.apache.directory.api.version},
                 org.apache.directory.api.ldap.model.csn;version=${org.apache.directory.api.version},
                 org.apache.directory.api.ldap.model.cursor;version=${org.apache.directory.api.version},
diff --git a/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java b/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
index 263ec91..a15f8ca 100644
--- a/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
+++ b/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
@@ -70,10 +70,12 @@ import org.apache.directory.server.xdbm.search.impl.DefaultOptimizer;
 import org.apache.directory.server.xdbm.search.impl.DefaultSearchEngine;
 import org.apache.directory.server.xdbm.search.impl.EvaluatorBuilder;
 import org.apache.directory.server.xdbm.search.impl.NoOpOptimizer;
-import org.ehcache.Cache;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
+
 import jdbm.RecordManager;
 import jdbm.helper.MRU;
 import jdbm.recman.BaseRecordManager;
@@ -533,17 +535,7 @@ public class JdbmPartition extends AbstractBTreePartition
                 buildUserIndex( beginReadTransaction(), indexToBuild );
             }
 
-            if ( cacheService != null )
-            {
-                entryCache = cacheService.getCache( getId(), String.class, Entry.class );
-
-                //int cacheSizeConfig = ( int ) entryCache.getCacheConfiguration().getMaxEntriesLocalHeap();
-
-                //if ( cacheSizeConfig < cacheSize )
-                //{
-                //    entryCache.getCacheConfiguration().setMaxEntriesLocalHeap( cacheSize );
-                //}
-            }
+            entryCache = Caffeine.newBuilder().maximumSize( cacheSize ).build();
 
             // Initialization of the context entry
             if ( ( suffixDn != null ) && ( contextEntry != null ) )
@@ -884,7 +876,7 @@ public class JdbmPartition extends AbstractBTreePartition
         {
             if ( entryCache != null )
             {
-                entryCache.clear();
+                entryCache.invalidateAll();
             }
         }
 
@@ -951,20 +943,20 @@ public class JdbmPartition extends AbstractBTreePartition
                     entry = ( ( ClonedServerEntry ) entry ).getOriginalEntry();
                 }
 
-                entryCache.replace( id, entry );
+                entryCache.put( id, entry );
             }
             else if ( ( opCtx instanceof MoveOperationContext )
                 || ( opCtx instanceof MoveAndRenameOperationContext )
                 || ( opCtx instanceof RenameOperationContext ) )
             {
                 // clear the cache it is not worth updating all the children
-                entryCache.clear();
+                entryCache.invalidateAll();
             }
             else if ( opCtx instanceof DeleteOperationContext )
             {
                 // delete the entry
                 DeleteOperationContext delCtx = ( DeleteOperationContext ) opCtx;
-                entryCache.remove( delCtx.getEntry().get( SchemaConstants.ENTRY_UUID_AT ).getString() );
+                entryCache.invalidate( delCtx.getEntry().get( SchemaConstants.ENTRY_UUID_AT ).getString() );
             }
         }
         catch ( LdapException e )
@@ -977,7 +969,7 @@ public class JdbmPartition extends AbstractBTreePartition
     @Override
     public Entry lookupCache( String id )
     {
-        return ( entryCache != null ) ? entryCache.get( id ) : null;
+        return ( entryCache != null ) ? entryCache.getIfPresent( id ) : null;
     }
 
 
diff --git a/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java b/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
index 99fa0d4..8256edb 100644
--- a/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
+++ b/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
@@ -60,7 +60,6 @@ import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.api.util.exception.Exceptions;
 import org.apache.directory.server.constants.ApacheSchemaConstants;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.CoreSession;
 import org.apache.directory.server.core.api.DirectoryService;
 import org.apache.directory.server.core.api.DnFactory;
@@ -117,7 +116,6 @@ public class JdbmStoreTest
     /** The SN AttributeType instance */
     private static AttributeType SN_AT;
 
-    private static CacheService cacheService;
     private PartitionTxn partitionTxn;
     
     /** The recordManager used */
@@ -152,10 +150,7 @@ public class JdbmStoreTest
         SN_AT = schemaManager.getAttributeType( SchemaConstants.SN_AT );
         APACHE_ALIAS_AT = schemaManager.getAttributeType( ApacheSchemaConstants.APACHE_ALIAS_AT );
 
-        cacheService = new CacheService();
-        cacheService.initialize( null );
-        dnFactory = new DefaultDnFactory( schemaManager, 
-            cacheService.getCache( "dnCache", String.class, Dn.class ) );
+        dnFactory = new DefaultDnFactory( schemaManager, 100 );
     }
 
 
@@ -183,7 +178,6 @@ public class JdbmStoreTest
         Dn suffixDn = new Dn( schemaManager, "o=Good Times Co." );
         partition.setSuffixDn( suffixDn );
 
-        partition.setCacheService( cacheService );
         partition.initialize();
 
         StoreUtils.loadExampleData( partition, schemaManager );
@@ -248,7 +242,6 @@ public class JdbmStoreTest
         store2.addIndex( new JdbmIndex( SchemaConstants.OU_AT_OID, false ) );
         store2.addIndex( new JdbmIndex( SchemaConstants.UID_AT_OID, false ) );
         store2.setSuffixDn( EXAMPLE_COM );
-        store2.setCacheService( cacheService );
         store2.initialize();
 
         // inject context entry
diff --git a/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/PartitionTreeTest.java b/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/PartitionTreeTest.java
index 88e4eed..9e959d6 100644
--- a/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/PartitionTreeTest.java
+++ b/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/PartitionTreeTest.java
@@ -38,7 +38,6 @@ import org.apache.directory.api.ldap.schema.loader.LdifSchemaLoader;
 import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.api.ldap.util.tree.DnNode;
 import org.apache.directory.api.util.exception.Exceptions;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.DnFactory;
 import org.apache.directory.server.core.api.partition.Partition;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.DupsContainerCursorTest;
@@ -84,10 +83,7 @@ public class PartitionTreeTest
             fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
         }
 
-        CacheService cacheService = new CacheService();
-        cacheService.initialize( null );
-        dnFactory = new DefaultDnFactory( schemaManager, 
-            cacheService.getCache( "dnCache", String.class, Dn.class ) );
+        dnFactory = new DefaultDnFactory( schemaManager, 100 );
     }
 
 
diff --git a/kerberos-codec/pom.xml b/kerberos-codec/pom.xml
index 918e1aa..011dd02 100644
--- a/kerberos-codec/pom.xml
+++ b/kerberos-codec/pom.xml
@@ -69,8 +69,8 @@
     </dependency>
     
     <dependency>
-      <groupId>org.ehcache</groupId>
-      <artifactId>ehcache</artifactId>
+      <groupId>com.github.ben-manes.caffeine</groupId>
+      <artifactId>caffeine</artifactId>
     </dependency>
   </dependencies>
 
@@ -134,7 +134,7 @@
                 javax.crypto,
                 javax.crypto.spec,
                 javax.security.auth.kerberos,
-                org.ehcache;version=${ehcache.version},
+                com.github.benmanes.caffeine.cache;bundle-version=${caffeine.version},
                 org.apache.directory.api.asn1;version=${org.apache.directory.api.version},
                 org.apache.directory.api.asn1.actions;version=${org.apache.directory.api.version},
                 org.apache.directory.api.asn1.ber;version=${org.apache.directory.api.version},
diff --git a/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/replay/ReplayCacheImpl.java b/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/replay/ReplayCacheImpl.java
index 58aa5a0..16d37c9 100644
--- a/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/replay/ReplayCacheImpl.java
+++ b/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/shared/replay/ReplayCacheImpl.java
@@ -21,14 +21,17 @@ package org.apache.directory.server.kerberos.shared.replay;
 
 
 import java.io.Serializable;
+import java.time.Duration;
 
 import javax.security.auth.kerberos.KerberosPrincipal;
 
 import org.apache.directory.shared.kerberos.KerberosTime;
-import org.ehcache.Cache;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
+
 
 /**
  * "The replay cache will store at least the server name, along with the client name,
@@ -44,8 +47,8 @@ public class ReplayCacheImpl implements ReplayCache
 
     private static final Logger LOG = LoggerFactory.getLogger( ReplayCacheImpl.class );
 
-    /** ehcache based storage to store the entries */
-    private Cache< String, Object > cache;
+    /** Caffeine based storage to store the entries */
+    Cache<String, Object> cache;
 
     /** default clock skew */
     private static final long DEFAULT_CLOCK_SKEW = 5L * KerberosTime.MINUTE;
@@ -139,36 +142,15 @@ public class ReplayCacheImpl implements ReplayCache
 
     /**
      * Creates a new instance of InMemoryReplayCache. Sets the
-     * delay between each cleaning run to 5 seconds.
-     */
-    public ReplayCacheImpl( Cache < String, Object > cache )
-    {
-        this.cache = cache;
-    }
-
-
-    /**
-     * Creates a new instance of InMemoryReplayCache. Sets the
      * delay between each cleaning run to 5 seconds. Sets the
      * clockSkew to the given value
      * 
      * @param clockSkew the allowed skew (milliseconds)
      */
-    public ReplayCacheImpl( Cache< String, Object > cache, long clockSkew )
-    {
-        this.cache = cache;
-        this.clockSkew = clockSkew;
-    }
-
-
-    /**
-     * Sets the clock skew.
-     *
-     * @param clockSkew
-     */
-    public void setClockSkew( long clockSkew )
+    public ReplayCacheImpl( long clockSkew )
     {
         this.clockSkew = clockSkew;
+        this.cache = Caffeine.newBuilder().expireAfterWrite( Duration.ofMillis( clockSkew )).build();
     }
 
 
@@ -180,7 +162,7 @@ public class ReplayCacheImpl implements ReplayCache
     {
         ReplayCacheEntry entry = new ReplayCacheEntry( serverPrincipal, 
             clientPrincipal, clientTime, clientMicroSeconds );
-        ReplayCacheEntry found = ( ReplayCacheEntry ) cache.get( entry.createKey() );
+        ReplayCacheEntry found = ( ReplayCacheEntry ) cache.getIfPresent( entry.createKey() );
 
         if ( found == null )
         {
@@ -214,6 +196,6 @@ public class ReplayCacheImpl implements ReplayCache
     public void clear()
     {
         LOG.debug( "removing all the elements from cache" );
-        cache.clear();
+        cache.invalidateAll();
     }
 }
diff --git a/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/replay/ReplayCacheImplTest.java b/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/replay/ReplayCacheImplTest.java
index 1de75b1..4827553 100644
--- a/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/replay/ReplayCacheImplTest.java
+++ b/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/replay/ReplayCacheImplTest.java
@@ -20,29 +20,22 @@
 package org.apache.directory.server.kerberos.shared.replay;
 
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
-import java.time.Duration;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
 
 import javax.security.auth.kerberos.KerberosPrincipal;
 
+import org.apache.commons.lang3.tuple.Triple;
 import org.apache.directory.junit.tools.MultiThreadedMultiInvoker;
 import org.apache.directory.shared.kerberos.KerberosTime;
 import org.apache.directory.shared.kerberos.codec.types.PrincipalNameType;
-import org.ehcache.Cache;
-import org.ehcache.Cache.Entry;
-import org.ehcache.CacheManager;
-import org.ehcache.Status;
-import org.ehcache.config.builders.CacheConfigurationBuilder;
-import org.ehcache.config.builders.CacheManagerBuilder;
-import org.ehcache.config.builders.ExpiryPolicyBuilder;
-import org.ehcache.config.builders.ResourcePoolsBuilder;
-
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -65,83 +58,76 @@ public class ReplayCacheImplTest
 
 
     /**
-     * Test that the cache is working well. We will create a new entry
-     * every 500 ms, with 4 different serverPrincipals.
-     *
-     * After this period of time, we should only have 2 entries in the cache
+     * Test that the cache is working well.
+     * We will create 4 new entries, with 4 different serverPrincipals.
+     * Those 4 entries should remain in cache and replay should be detected
+     * After expiration time the entries should have been expired.
      */
     @Test
     public void testCacheSetting() throws Exception
     {
-        CacheManager cacheManager = null;
-
         try
         {
             long clockSkew = 1000; // 1 sec
 
-            cacheManager = CacheManagerBuilder.newCacheManagerBuilder().build();
-            
-            cacheManager.init();
-
-            Cache< String, Object > ehCache = cacheManager.createCache( 
-                    "kdcReplayCache", 
-                    CacheConfigurationBuilder.newCacheConfigurationBuilder(
-                            String.class, 
-                            Object.class, 
-                            ResourcePoolsBuilder.heap(4)
-                    )
-                        .withExpiry(
-                            ExpiryPolicyBuilder
-                                .timeToIdleExpiration( Duration.ofMillis( 1000 ) )
-                                )
-                        .withExpiry(ExpiryPolicyBuilder.timeToLiveExpiration( Duration.ofMillis( 1000 )))
-            );
-            
-            ReplayCacheImpl cache = new ReplayCacheImpl( ehCache, clockSkew );
-
-            int i = 0;
+            ReplayCacheImpl cache = new ReplayCacheImpl( clockSkew );
 
             // Inject 4 entries
-            while ( i < 4 )
+            List<Triple<KerberosPrincipal, KerberosPrincipal, KerberosTime>> triples = new ArrayList<>();
+            for ( int i = 0; i < 4; i++ )
             {
                 KerberosPrincipal serverPrincipal = new KerberosPrincipal( "server" + i + "@APACHE.ORG",
                     PrincipalNameType.KRB_NT_PRINCIPAL.getValue() );
                 KerberosPrincipal clientPrincipal = new KerberosPrincipal( "client" + i + "@APACHE.ORG",
                     PrincipalNameType.KRB_NT_PRINCIPAL.getValue() );
+                KerberosTime clientTime = new KerberosTime( System.currentTimeMillis() );
 
-                cache.save( serverPrincipal, clientPrincipal, new KerberosTime( System.currentTimeMillis() ), 0 );
+                cache.save( serverPrincipal, clientPrincipal, clientTime, 0 );
 
-                i++;
+                triples.add( Triple.of( serverPrincipal, clientPrincipal, clientTime ) );
             }
 
-            List<String> keys = new ArrayList<>();
-            Iterator<Entry<String, Object>> it = ehCache.iterator();
-            
-            while (it.hasNext())
+            // Get the 4 cache keys
+            Set<String> keys = cache.cache.asMap().keySet();
+            assertEquals( 4, keys.size() );
+            assertEquals( 4L, cache.cache.estimatedSize() );
+
+            // Wait a bit without exceeding timetolive time
+            Thread.sleep( 200L );
+
+            // Verify that cache entries are valid and replay is detected
+            for ( String key : keys )
             {
-                keys.add(it.next().getKey());
+                assertNotNull( cache.cache.getIfPresent( key ) );
+            }
+            for ( Triple<KerberosPrincipal, KerberosPrincipal, KerberosTime> triple : triples )
+            {
+                boolean isReplay = cache.isReplay( triple.getLeft(), triple.getMiddle(), triple.getRight(), 0 );
+                assertTrue( isReplay );
             }
-
-            // We should have 4 entries
-            assertTrue( keys.size() != 0 );
 
             // Wait till the timetolive time exceeds
-            Thread.sleep( 1200 );
+            Thread.sleep( 1000L );
+
+            // Verify that cache entries are expired and no replay is detected
+            for ( Triple<KerberosPrincipal, KerberosPrincipal, KerberosTime> triple : triples )
+            {
+                boolean isReplay = cache.isReplay( triple.getLeft(), triple.getMiddle(), triple.getRight(), 0 );
+                assertFalse( isReplay );
+            }
 
             // then access the cache so that the objects present in the cache will be expired
-            for ( String k : keys )
+            for ( String key : keys )
             {
-                assertNull( ehCache.get( k ) );
+                assertNull( cache.cache.getIfPresent( key ) );
             }
 
-            assertFalse( ehCache.iterator().hasNext() );
+            // After forced cache cleanup the size is recalculated
+            cache.cache.cleanUp();
+            assertEquals( 0L, cache.cache.estimatedSize() );
         }
         finally
         {
-            if ( cacheManager != null && cacheManager.getStatus() != Status.UNINITIALIZED)
-            {
-                cacheManager.close();
-            }
         }
     }
 }
diff --git a/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/LdifPartitionTest.java b/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/LdifPartitionTest.java
index 0952bc5..bf81940 100644
--- a/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/LdifPartitionTest.java
+++ b/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/LdifPartitionTest.java
@@ -56,7 +56,6 @@ import org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtr
 import org.apache.directory.api.ldap.schema.loader.LdifSchemaLoader;
 import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.api.util.exception.Exceptions;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.CoreSession;
 import org.apache.directory.server.core.api.DirectoryService;
 import org.apache.directory.server.core.api.DnFactory;
@@ -99,7 +98,6 @@ public class LdifPartitionTest
     private static SchemaManager schemaManager = null;
     private static DnFactory dnFactory;
     private static CsnFactory defaultCSNFactory;
-    private static CacheService cacheService;
 
     @Rule
     public TemporaryFolder folder = new TemporaryFolder();
@@ -132,10 +130,7 @@ public class LdifPartitionTest
 
         defaultCSNFactory = new CsnFactory( 0 );
 
-        cacheService = new CacheService();
-        cacheService.initialize( null );
-        dnFactory = new DefaultDnFactory( schemaManager, 
-            cacheService.getCache( "dnCache", String.class, Dn.class ) );
+        dnFactory = new DefaultDnFactory( schemaManager, 100 );
     }
 
 
@@ -154,7 +149,6 @@ public class LdifPartitionTest
         partition.setSchemaManager( schemaManager );
         partition.setPartitionPath( wkdir.toURI() );
 
-        partition.setCacheService( cacheService );
         partition.initialize();
 
         Entry entry = createEntry( "ou=test, ou=system" );
diff --git a/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionSingeValueAttribute.java b/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionSingeValueAttribute.java
index aeabfb7..3503975 100644
--- a/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionSingeValueAttribute.java
+++ b/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionSingeValueAttribute.java
@@ -68,7 +68,6 @@ import org.apache.directory.api.ldap.schema.loader.LdifSchemaLoader;
 import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.api.util.exception.Exceptions;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.CoreSession;
 import org.apache.directory.server.core.api.DirectoryService;
 import org.apache.directory.server.core.api.DnFactory;
@@ -125,8 +124,6 @@ public class SingleFileLdifPartitionSingeValueAttribute
     @Rule
     public TemporaryFolder folder = new TemporaryFolder();
 
-    private static CacheService cacheService;
-
 
     @BeforeClass
     public static void init() throws Exception
@@ -176,10 +173,7 @@ public class SingleFileLdifPartitionSingeValueAttribute
 
         contextEntry = new ClonedServerEntry( new DefaultEntry( schemaManager, ldifEntry.getEntry() ) );
 
-        cacheService = new CacheService();
-        cacheService.initialize( null );
-        dnFactory = new DefaultDnFactory( schemaManager, 
-            cacheService.getCache( "dnCache", String.class, Dn.class ) );
+        dnFactory = new DefaultDnFactory( schemaManager, 100 );
     }
 
 
@@ -249,7 +243,6 @@ public class SingleFileLdifPartitionSingeValueAttribute
         partition.setPartitionPath( new File( fileName ).toURI() );
         partition.setSuffixDn( new Dn( schemaManager, "ou=test,ou=system" ) );
         partition.setSchemaManager( schemaManager );
-        partition.setCacheService( cacheService );
         partition.initialize();
 
         return partition;
diff --git a/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java b/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java
index 551a2e6..779252f 100644
--- a/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java
+++ b/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java
@@ -68,7 +68,6 @@ import org.apache.directory.api.ldap.schema.loader.LdifSchemaLoader;
 import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.api.util.exception.Exceptions;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.CoreSession;
 import org.apache.directory.server.core.api.DirectoryService;
 import org.apache.directory.server.core.api.DnFactory;
@@ -123,8 +122,6 @@ public class SingleFileLdifPartitionTest
     @Rule
     public TemporaryFolder folder = new TemporaryFolder();
 
-    private static CacheService cacheService;
-
 
     @BeforeClass
     public static void init() throws Exception
@@ -174,10 +171,7 @@ public class SingleFileLdifPartitionTest
 
         contextEntry = new ClonedServerEntry( new DefaultEntry( schemaManager, ldifEntry.getEntry() ) );
 
-        cacheService = new CacheService();
-        cacheService.initialize( null );
-        dnFactory = new DefaultDnFactory( schemaManager, 
-            cacheService.getCache( "dnCache", String.class, Dn.class ) );
+        dnFactory = new DefaultDnFactory( schemaManager, 100 );
     }
 
 
@@ -247,7 +241,6 @@ public class SingleFileLdifPartitionTest
         partition.setPartitionPath( new File( fileName ).toURI() );
         partition.setSuffixDn( new Dn( schemaManager, "ou=test,ou=system" ) );
         partition.setSchemaManager( schemaManager );
-        partition.setCacheService( cacheService );
         partition.initialize();
 
         return partition;
diff --git a/mavibot-partition/pom.xml b/mavibot-partition/pom.xml
index ea03943..0bf0246 100644
--- a/mavibot-partition/pom.xml
+++ b/mavibot-partition/pom.xml
@@ -133,7 +133,7 @@
                 org.apache.directory.server.core.partition.impl.btree.mavibot;version=${project.version}
             </Export-Package>
             <Import-Package>
-                org.ehcache;version=${ehcache.version},
+                com.github.benmanes.caffeine.cache;bundle-version=${caffeine.version},
                 org.apache.directory.api.ldap.model.constants;version=${org.apache.directory.api.version},
                 org.apache.directory.api.ldap.model.cursor;version=${org.apache.directory.api.version},
                 org.apache.directory.api.ldap.model.entry;version=${org.apache.directory.api.version},
diff --git a/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotPartition.java b/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotPartition.java
index 42ea6a9..34c54d0 100644
--- a/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotPartition.java
+++ b/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotPartition.java
@@ -30,7 +30,6 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import org.ehcache.Cache;
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.cursor.Cursor;
 import org.apache.directory.api.ldap.model.cursor.Tuple;
@@ -67,6 +66,9 @@ import org.apache.directory.server.xdbm.search.impl.NoOpOptimizer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
+
 
 /**
  * A Mavibot partition
@@ -227,10 +229,7 @@ public class MavibotPartition extends AbstractBTreePartition
                         deleteUnusedIndexFiles( allIndices, allIndexDbFiles );
             */
 
-            if ( cacheService != null )
-            {
-                entryCache = cacheService.getCache( getId(), String.class, Entry.class );
-            }
+            entryCache = Caffeine.newBuilder().maximumSize( cacheSize ).build();
 
             // We are done !
             initialized = true;
@@ -321,7 +320,7 @@ public class MavibotPartition extends AbstractBTreePartition
         {
             if ( entryCache != null )
             {
-                entryCache.clear();
+                entryCache.invalidateAll();
             }
         }
 
@@ -445,7 +444,7 @@ public class MavibotPartition extends AbstractBTreePartition
     @Override
     public Entry lookupCache( String id )
     {
-        return ( entryCache != null ) ? entryCache.get( id ) : null;
+        return ( entryCache != null ) ? entryCache.getIfPresent( id ) : null;
     }
 
 
@@ -488,19 +487,19 @@ public class MavibotPartition extends AbstractBTreePartition
                     entry = ( ( ClonedServerEntry ) entry ).getOriginalEntry();
                 }
 
-                entryCache.replace( id, entry );
+                entryCache.put( id, entry );
             }
             else if ( ( opCtx instanceof MoveOperationContext ) || ( opCtx instanceof MoveAndRenameOperationContext )
                 || ( opCtx instanceof RenameOperationContext ) )
             {
                 // clear the cache it is not worth updating all the children
-                entryCache.clear();
+                entryCache.invalidateAll();
             }
             else if ( opCtx instanceof DeleteOperationContext )
             {
                 // delete the entry
                 DeleteOperationContext delCtx = ( DeleteOperationContext ) opCtx;
-                entryCache.remove( delCtx.getEntry().get( SchemaConstants.ENTRY_UUID_AT ).getString() );
+                entryCache.invalidate( delCtx.getEntry().get( SchemaConstants.ENTRY_UUID_AT ).getString() );
             }
         }
         catch ( LdapException e )
diff --git a/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotStoreTest.java b/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotStoreTest.java
index 0fdd337..26984d4 100644
--- a/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotStoreTest.java
+++ b/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotStoreTest.java
@@ -58,7 +58,6 @@ import org.apache.directory.api.util.Strings;
 import org.apache.directory.api.util.exception.Exceptions;
 import org.apache.directory.mavibot.btree.RecordManager;
 import org.apache.directory.server.constants.ApacheSchemaConstants;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.CoreSession;
 import org.apache.directory.server.core.api.DirectoryService;
 import org.apache.directory.server.core.api.DnFactory;
@@ -121,7 +120,6 @@ public class MavibotStoreTest
 
     private RecordManager recordMan;
 
-    private static CacheService cacheService;
     private PartitionTxn partitionTxn;
 
     @Rule
@@ -160,10 +158,7 @@ public class MavibotStoreTest
         SN_AT = schemaManager.getAttributeType( SchemaConstants.SN_AT );
         APACHE_ALIAS_AT = schemaManager.getAttributeType( ApacheSchemaConstants.APACHE_ALIAS_AT );
 
-        cacheService = new CacheService();
-        cacheService.initialize( null );
-        dnFactory = new DefaultDnFactory( schemaManager, 
-            cacheService.getCache( "dnCache", String.class, Dn.class ) );
+        dnFactory = new DefaultDnFactory( schemaManager, 100 );
     }
 
 
@@ -193,7 +188,6 @@ public class MavibotStoreTest
         Dn suffixDn = new Dn( schemaManager, "o=Good Times Co." );
         store.setSuffixDn( suffixDn );
 
-        store.setCacheService( cacheService );
         store.initialize();
 
         recordMan = store.getRecordMan();
@@ -244,7 +238,6 @@ public class MavibotStoreTest
         store2.addIndex( new MavibotIndex( SchemaConstants.OU_AT_OID, false ) );
         store2.addIndex( new MavibotIndex( SchemaConstants.UID_AT_OID, false ) );
         store2.setSuffixDn( EXAMPLE_COM );
-        store2.setCacheService( cacheService );
         store2.initialize();
 
         // inject context entry
diff --git a/osgi-integ/src/test/java/org/apache/directory/server/osgi/integ/ServerCoreAnnotationsOsgiTest.java b/osgi-integ/src/test/java/org/apache/directory/server/osgi/integ/ServerCoreAnnotationsOsgiTest.java
index 818aad8..e6b98ed 100644
--- a/osgi-integ/src/test/java/org/apache/directory/server/osgi/integ/ServerCoreAnnotationsOsgiTest.java
+++ b/osgi-integ/src/test/java/org/apache/directory/server/osgi/integ/ServerCoreAnnotationsOsgiTest.java
@@ -43,6 +43,7 @@ public class ServerCoreAnnotationsOsgiTest extends ServerOsgiTestBase
         factory.init( "foo" );
         DirectoryService ds = factory.getDirectoryService();
         assertNotNull( ds );
+        assertNotNull( ds.getDnFactory() );
     }
 
 }
diff --git a/osgi-integ/src/test/java/org/apache/directory/server/osgi/integ/ServerCoreApiOsgiTest.java b/osgi-integ/src/test/java/org/apache/directory/server/osgi/integ/ServerCoreApiOsgiTest.java
index 87c6d13..22ba120 100644
--- a/osgi-integ/src/test/java/org/apache/directory/server/osgi/integ/ServerCoreApiOsgiTest.java
+++ b/osgi-integ/src/test/java/org/apache/directory/server/osgi/integ/ServerCoreApiOsgiTest.java
@@ -22,7 +22,6 @@ package org.apache.directory.server.osgi.integ;
 
 import org.apache.directory.api.ldap.model.name.Dn;
 import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.LdapPrincipal;
 import org.apache.directory.server.core.api.administrative.SubschemaAAP;
 import org.apache.directory.server.core.api.entry.ClonedServerEntry;
@@ -43,7 +42,6 @@ public class ServerCoreApiOsgiTest extends ServerOsgiTestBase
     @Override
     protected void useBundleClasses() throws Exception
     {
-        new CacheService();
         new LdapPrincipal();
         new SubschemaAAP( new Dn( "cn=foo" ), "uuid" );
         new ClonedServerEntry();
diff --git a/osgi-integ/src/test/java/org/apache/directory/server/osgi/integ/ServerCoreSharedOsgiTest.java b/osgi-integ/src/test/java/org/apache/directory/server/osgi/integ/ServerCoreSharedOsgiTest.java
index 0558229..477658b 100644
--- a/osgi-integ/src/test/java/org/apache/directory/server/osgi/integ/ServerCoreSharedOsgiTest.java
+++ b/osgi-integ/src/test/java/org/apache/directory/server/osgi/integ/ServerCoreSharedOsgiTest.java
@@ -20,7 +20,10 @@
 package org.apache.directory.server.osgi.integ;
 
 
+import static org.junit.Assert.assertSame;
+
 import org.apache.directory.api.ldap.model.entry.DefaultEntry;
+import org.apache.directory.api.ldap.model.name.Dn;
 import org.apache.directory.server.core.shared.DefaultDnFactory;
 import org.apache.directory.server.core.shared.NullStringSerializer;
 import org.apache.directory.server.core.shared.partition.DefaultPartitionNexus;
@@ -39,7 +42,11 @@ public class ServerCoreSharedOsgiTest extends ServerOsgiTestBase
     @Override
     protected void useBundleClasses() throws Exception
     {
-        new DefaultDnFactory( null, null );
+        DefaultDnFactory dnFactory = new DefaultDnFactory( null, 100 );
+        Dn dn1 = dnFactory.create( "cn=foo" );
+        Dn dn2 = dnFactory.create( "cn=foo" );
+        assertSame( dn1, dn2 );
+
         NullStringSerializer.INSTANCE.serialize( null );
         NullStringSerializer.INSTANCE.deserialize( null );
         new DefaultPartitionNexus( new DefaultEntry() );
diff --git a/osgi-integ/src/test/java/org/apache/directory/server/osgi/integ/ServerJdbmPartitionOsgiTest.java b/osgi-integ/src/test/java/org/apache/directory/server/osgi/integ/ServerJdbmPartitionOsgiTest.java
index 5fa9abd..6c7ec1f 100644
--- a/osgi-integ/src/test/java/org/apache/directory/server/osgi/integ/ServerJdbmPartitionOsgiTest.java
+++ b/osgi-integ/src/test/java/org/apache/directory/server/osgi/integ/ServerJdbmPartitionOsgiTest.java
@@ -45,7 +45,7 @@ public class ServerJdbmPartitionOsgiTest extends ServerOsgiTestBase
     {
         new JdbmIndex<String>( "foo", false );
         SchemaManager schemaManager = new DefaultSchemaManager();
-        new JdbmPartition( schemaManager, new DefaultDnFactory( schemaManager, null ) );
+        new JdbmPartition( schemaManager, new DefaultDnFactory( schemaManager, 100 ) );
         new ParentIdAndRdnSerializer( schemaManager );
         new DnSerializer( schemaManager ).serialize( new Dn( "cn=foo" ) );
     }
diff --git a/osgi-integ/src/test/java/org/apache/directory/server/osgi/integ/ServerMavibotPartitionOsgiTest.java b/osgi-integ/src/test/java/org/apache/directory/server/osgi/integ/ServerMavibotPartitionOsgiTest.java
index 0c70b27..5668932 100644
--- a/osgi-integ/src/test/java/org/apache/directory/server/osgi/integ/ServerMavibotPartitionOsgiTest.java
+++ b/osgi-integ/src/test/java/org/apache/directory/server/osgi/integ/ServerMavibotPartitionOsgiTest.java
@@ -46,7 +46,7 @@ public class ServerMavibotPartitionOsgiTest extends ServerOsgiTestBase
     {
         new MavibotIndex<String>( "foo", false );
         SchemaManager schemaManager = new DefaultSchemaManager();
-        new MavibotPartition( schemaManager, new DefaultDnFactory( schemaManager, null ) );
+        new MavibotPartition( schemaManager, new DefaultDnFactory( schemaManager, 100 ) );
         new DnSerializer().serialize( new Dn( "cn=foo" ) );
 
         BTree<Object, Object> mavibotBTree = BTreeFactory.createInMemoryBTree();
diff --git a/pom.xml b/pom.xml
index 4bc3dc0..8d26e5d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -64,8 +64,7 @@
     <commons.net.version>3.6</commons.net.version>
     <commons.pool.version>2.6.1</commons.pool.version>
     <dnsjava.version>2.1.8</dnsjava.version>
-    <!-- OSGi related issue in ehcache 3.6.x: https://github.com/ehcache/ehcache3/issues/2554 -->
-    <ehcache.version>3.5.3</ehcache.version>
+    <caffeine.version>2.7.0</caffeine.version>
     <findbugs.annotations.version>1.0.0</findbugs.annotations.version>
     <jetty.version>9.4.14.v20181114</jetty.version>
     <!-- The Jetty bundle exports are using version 9.4.5, not 9.4.5.v20170502... -->
@@ -1228,9 +1227,19 @@
       </dependency>
       
       <dependency>
-        <groupId>org.ehcache</groupId>
-        <artifactId>ehcache</artifactId>
-        <version>${ehcache.version}</version>
+        <groupId>com.github.ben-manes.caffeine</groupId>
+        <artifactId>caffeine</artifactId>
+        <version>${caffeine.version}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>com.google.errorprone</groupId>
+            <artifactId>error_prone_annotations</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>org.checkerframework</groupId>
+            <artifactId>checker-qual</artifactId>
+           </exclusion>
+         </exclusions>
       </dependency>
     </dependencies>
   </dependencyManagement>
diff --git a/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java b/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java
index 348d114..aabf43d 100644
--- a/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java
+++ b/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java
@@ -26,8 +26,6 @@ import java.util.List;
 
 import javax.security.auth.kerberos.KerberosPrincipal;
 
-import org.ehcache.Cache;
-
 import org.apache.directory.server.changepw.protocol.ChangePasswordProtocolHandler;
 import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.kerberos.shared.replay.ReplayCacheImpl;
diff --git a/protocol-kerberos/pom.xml b/protocol-kerberos/pom.xml
index aed97c0..f13114f 100644
--- a/protocol-kerberos/pom.xml
+++ b/protocol-kerberos/pom.xml
@@ -72,10 +72,6 @@
       <artifactId>mina-core</artifactId>
     </dependency>
 
-    <dependency>
-      <groupId>org.ehcache</groupId>
-      <artifactId>ehcache</artifactId>
-    </dependency>
   </dependencies>
 
   <build>
@@ -139,7 +135,7 @@
                 javax.naming,
                 javax.naming.directory,
                 javax.security.auth.kerberos,
-                org.ehcache;version=${ehcache.version},
+                com.github.benmanes.caffeine.cache;bundle-version=${caffeine.version},
                 org.apache.directory.api.asn1;version=${org.apache.directory.api.version},
                 org.apache.directory.api.asn1.ber;version=${org.apache.directory.api.version},
                 org.apache.directory.api.asn1.ber.tlv;version=${org.apache.directory.api.version},
diff --git a/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/changepwd/ChangePasswordServer.java b/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/changepwd/ChangePasswordServer.java
index b9b9b90..c92d652 100644
--- a/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/changepwd/ChangePasswordServer.java
+++ b/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/changepwd/ChangePasswordServer.java
@@ -37,7 +37,6 @@ import org.apache.directory.server.protocol.shared.transport.UdpTransport;
 import org.apache.mina.core.service.IoAcceptor;
 import org.apache.mina.transport.socket.DatagramSessionConfig;
 import org.apache.mina.transport.socket.SocketAcceptor;
-import org.ehcache.Cache;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -94,9 +93,7 @@ public class ChangePasswordServer extends DirectoryBackedService
 
         LOG.debug( "initializing the changepassword replay cache" );
 
-        Cache< String, Object > cache = getDirectoryService().getCacheService().
-            getCache( "changePwdReplayCache", String.class, Object.class );
-        replayCache = new ReplayCacheImpl( cache );
+        replayCache = new ReplayCacheImpl( config.getAllowableClockSkew() );
 
         for ( Transport transport : transports )
         {
diff --git a/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java b/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java
index e23488f..32a4924 100644
--- a/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java
+++ b/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java
@@ -39,7 +39,6 @@ import org.apache.mina.core.filterchain.IoFilterChainBuilder;
 import org.apache.mina.core.service.IoAcceptor;
 import org.apache.mina.filter.codec.ProtocolCodecFilter;
 import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
-import org.ehcache.Cache;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -110,9 +109,7 @@ public class KdcServer extends DirectoryBackedService
 
         LOG.debug( "initializing the kerberos replay cache" );
 
-        Cache< String, Object > cache = getDirectoryService().getCacheService().
-            getCache( "kdcReplayCache", String.class, Object.class );
-        replayCache = new ReplayCacheImpl( cache, config.getAllowableClockSkew() );
+        replayCache = new ReplayCacheImpl( config.getAllowableClockSkew() );
 
         // Kerberos can use UDP or TCP
         for ( Transport transport : transports )
diff --git a/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionInitializer.java b/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionInitializer.java
index 9299f1a..5d11a07 100644
--- a/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionInitializer.java
+++ b/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionInitializer.java
@@ -32,7 +32,6 @@ import org.apache.directory.api.ldap.model.name.Dn;
 import org.apache.directory.api.ldap.model.schema.SchemaManager;
 import org.apache.directory.api.util.DateUtils;
 import org.apache.directory.server.constants.ServerDNConstants;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.DnFactory;
 import org.apache.directory.server.core.api.InstanceLayout;
 import org.apache.directory.server.core.api.interceptor.context.AddOperationContext;
@@ -58,8 +57,6 @@ public class ConfigPartitionInitializer
 
     private DnFactory dnFactory;
 
-    private CacheService cacheService;
-
 
     /**
      * Creates a new instance of ConfigPartitionHelper.
@@ -69,12 +66,11 @@ public class ConfigPartitionInitializer
      * @param cacheService the cache service
      * @param schemaManager the schema manager
      */
-    public ConfigPartitionInitializer( InstanceLayout instanceLayout, DnFactory dnFactory, CacheService cacheService,
+    public ConfigPartitionInitializer( InstanceLayout instanceLayout, DnFactory dnFactory,
         SchemaManager schemaManager )
     {
         this.instanceLayout = instanceLayout;
         this.dnFactory = dnFactory;
-        this.cacheService = cacheService;
         this.schemaManager = schemaManager;
     }
 
@@ -94,7 +90,6 @@ public class ConfigPartitionInitializer
         configPartition.setPartitionPath( instanceLayout.getConfDirectory().toURI() );
         configPartition.setSuffixDn( new Dn( schemaManager, "ou=config" ) );
         configPartition.setSchemaManager( schemaManager );
-        configPartition.setCacheService( cacheService );
 
         File newConfigDir = new File( instanceLayout.getConfDirectory(), configPartition.getSuffixDn().getName() );
 
diff --git a/server-config/src/test/java/org/apache/directory/server/config/ChangePasswordConfigReaderTest.java b/server-config/src/test/java/org/apache/directory/server/config/ChangePasswordConfigReaderTest.java
index 411ed12..9b6e85c 100644
--- a/server-config/src/test/java/org/apache/directory/server/config/ChangePasswordConfigReaderTest.java
+++ b/server-config/src/test/java/org/apache/directory/server/config/ChangePasswordConfigReaderTest.java
@@ -37,7 +37,6 @@ import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.api.util.exception.Exceptions;
 import org.apache.directory.server.config.beans.ChangePasswordServerBean;
 import org.apache.directory.server.config.beans.ConfigBean;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.DnFactory;
 import org.apache.directory.server.core.partition.ldif.SingleFileLdifPartition;
 import org.apache.directory.server.core.shared.DefaultDnFactory;
@@ -63,7 +62,6 @@ public class ChangePasswordConfigReaderTest
 
     private static SchemaManager schemaManager;
     private static DnFactory dnFactory;
-    private static CacheService cacheService;
 
 
     @BeforeClass
@@ -101,10 +99,7 @@ public class ChangePasswordConfigReaderTest
             throw new Exception( "Schema load failed : " + Exceptions.printErrors( errors ) );
         }
 
-        cacheService = new CacheService();
-        cacheService.initialize( null );
-        dnFactory = new DefaultDnFactory( schemaManager, 
-            cacheService.getCache( "dnCache", String.class, Dn.class ) );
+        dnFactory = new DefaultDnFactory( schemaManager, 100 );
     }
 
 
@@ -127,7 +122,6 @@ public class ChangePasswordConfigReaderTest
         configPartition.setSuffixDn( new Dn( schemaManager, "ou=config" ) );
         configPartition.setSchemaManager( schemaManager );
 
-        configPartition.setCacheService( cacheService );
         configPartition.initialize();
         ConfigPartitionReader cpReader = new ConfigPartitionReader( configPartition );
 
diff --git a/server-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java b/server-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java
index d076429..42cf73f 100644
--- a/server-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java
+++ b/server-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java
@@ -37,7 +37,6 @@ import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.api.util.exception.Exceptions;
 import org.apache.directory.server.config.beans.ConfigBean;
 import org.apache.directory.server.config.beans.DirectoryServiceBean;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.DnFactory;
 import org.apache.directory.server.core.partition.ldif.SingleFileLdifPartition;
 import org.apache.directory.server.core.shared.DefaultDnFactory;
@@ -60,7 +59,6 @@ public class ConfigPartitionReaderTest
 {
     private static SchemaManager schemaManager;
     private static DnFactory dnFactory;
-    private static CacheService cacheService;
 
     private static File workDir = new File( System.getProperty( "java.io.tmpdir" ) + "/server-work" );
 
@@ -99,10 +97,7 @@ public class ConfigPartitionReaderTest
             throw new Exception( "Schema load failed : " + Exceptions.printErrors( errors ) );
         }
 
-        cacheService = new CacheService();
-        cacheService.initialize( null );
-        dnFactory = new DefaultDnFactory( schemaManager, 
-            cacheService.getCache( "dnCache", String.class, Dn.class ) );
+        dnFactory = new DefaultDnFactory( schemaManager, 100 );
     }
 
 
@@ -119,7 +114,6 @@ public class ConfigPartitionReaderTest
         configPartition.setSuffixDn( new Dn( schemaManager, "ou=config" ) );
         configPartition.setSchemaManager( schemaManager );
 
-        configPartition.setCacheService( cacheService );
         configPartition.initialize();
 
         ConfigPartitionReader cpReader = new ConfigPartitionReader( configPartition );
diff --git a/server-config/src/test/java/org/apache/directory/server/config/ConfigWriterTest.java b/server-config/src/test/java/org/apache/directory/server/config/ConfigWriterTest.java
index 76ac4aa..824c7be 100644
--- a/server-config/src/test/java/org/apache/directory/server/config/ConfigWriterTest.java
+++ b/server-config/src/test/java/org/apache/directory/server/config/ConfigWriterTest.java
@@ -44,7 +44,6 @@ import org.apache.directory.api.ldap.schema.loader.LdifSchemaLoader;
 import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.api.util.exception.Exceptions;
 import org.apache.directory.server.config.beans.ConfigBean;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.DnFactory;
 import org.apache.directory.server.core.partition.ldif.SingleFileLdifPartition;
 import org.apache.directory.server.core.shared.DefaultDnFactory;
@@ -67,7 +66,6 @@ public class ConfigWriterTest
 {
     private static SchemaManager schemaManager;
     private static DnFactory dnFactory;
-    private static CacheService cacheService;
 
     private static File workDir = new File( System.getProperty( "java.io.tmpdir" ) + "/server-work" );
 
@@ -105,10 +103,7 @@ public class ConfigWriterTest
             throw new Exception( "Schema load failed : " + Exceptions.printErrors( errors ) );
         }
 
-        cacheService = new CacheService();
-        cacheService.initialize( null );
-        dnFactory = new DefaultDnFactory( schemaManager, 
-            cacheService.getCache( "dnCache", String.class, Dn.class ) );
+        dnFactory = new DefaultDnFactory( schemaManager, 100 );
     }
 
 
@@ -125,7 +120,6 @@ public class ConfigWriterTest
         configPartition.setPartitionPath( new File( configFile ).toURI() );
         configPartition.setSuffixDn( new Dn( schemaManager, "ou=config" ) );
         configPartition.setSchemaManager( schemaManager );
-        configPartition.setCacheService( cacheService );
         configPartition.initialize();
 
         // Reading the config partition
diff --git a/server-config/src/test/java/org/apache/directory/server/config/HttpServerConfigReaderTest.java b/server-config/src/test/java/org/apache/directory/server/config/HttpServerConfigReaderTest.java
index d8e42cd..a200c6b 100644
--- a/server-config/src/test/java/org/apache/directory/server/config/HttpServerConfigReaderTest.java
+++ b/server-config/src/test/java/org/apache/directory/server/config/HttpServerConfigReaderTest.java
@@ -37,7 +37,6 @@ import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.api.util.exception.Exceptions;
 import org.apache.directory.server.config.beans.ConfigBean;
 import org.apache.directory.server.config.beans.HttpServerBean;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.DnFactory;
 import org.apache.directory.server.core.partition.ldif.SingleFileLdifPartition;
 import org.apache.directory.server.core.shared.DefaultDnFactory;
@@ -60,7 +59,6 @@ public class HttpServerConfigReaderTest
 {
     private static SchemaManager schemaManager;
     private static DnFactory dnFactory;
-    private static CacheService cacheService;
 
     private static File workDir = new File( System.getProperty( "java.io.tmpdir" ) + "/server-work" );
 
@@ -98,10 +96,7 @@ public class HttpServerConfigReaderTest
             throw new Exception( "Schema load failed : " + Exceptions.printErrors( errors ) );
         }
 
-        cacheService = new CacheService();
-        cacheService.initialize( null );
-        dnFactory = new DefaultDnFactory( schemaManager, 
-            cacheService.getCache( "dnCache", String.class, Dn.class ) );
+        dnFactory = new DefaultDnFactory( schemaManager, 100 );
     }
 
 
@@ -117,7 +112,6 @@ public class HttpServerConfigReaderTest
         configPartition.setSuffixDn( new Dn( schemaManager, "ou=config" ) );
         configPartition.setSchemaManager( schemaManager );
 
-        configPartition.setCacheService( cacheService );
         configPartition.initialize();
 
         ConfigPartitionReader cpReader = new ConfigPartitionReader( configPartition );
diff --git a/server-config/src/test/java/org/apache/directory/server/config/KerberosServerConfigReaderTest.java b/server-config/src/test/java/org/apache/directory/server/config/KerberosServerConfigReaderTest.java
index 5126011..41d42a2 100644
--- a/server-config/src/test/java/org/apache/directory/server/config/KerberosServerConfigReaderTest.java
+++ b/server-config/src/test/java/org/apache/directory/server/config/KerberosServerConfigReaderTest.java
@@ -37,7 +37,6 @@ import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.api.util.exception.Exceptions;
 import org.apache.directory.server.config.beans.ConfigBean;
 import org.apache.directory.server.config.beans.KdcServerBean;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.DnFactory;
 import org.apache.directory.server.core.partition.ldif.SingleFileLdifPartition;
 import org.apache.directory.server.core.shared.DefaultDnFactory;
@@ -62,7 +61,6 @@ public class KerberosServerConfigReaderTest
 
     private static SchemaManager schemaManager;
     private static DnFactory dnFactory;
-    private static CacheService cacheService;
 
 
     @BeforeClass
@@ -99,10 +97,7 @@ public class KerberosServerConfigReaderTest
             throw new Exception( "Schema load failed : " + Exceptions.printErrors( errors ) );
         }
 
-        cacheService = new CacheService();
-        cacheService.initialize( null );
-        dnFactory = new DefaultDnFactory( schemaManager, 
-            cacheService.getCache( "dnCache", String.class, Dn.class ) );
+        dnFactory = new DefaultDnFactory( schemaManager, 100 );
     }
 
 
@@ -118,7 +113,6 @@ public class KerberosServerConfigReaderTest
         configPartition.setSuffixDn( new Dn( schemaManager, "ou=config" ) );
         configPartition.setSchemaManager( schemaManager );
 
-        configPartition.setCacheService( cacheService );
         configPartition.initialize();
         ConfigPartitionReader cpReader = new ConfigPartitionReader( configPartition );
 
diff --git a/server-config/src/test/java/org/apache/directory/server/config/LdapServerConfigReaderTest.java b/server-config/src/test/java/org/apache/directory/server/config/LdapServerConfigReaderTest.java
index 1c34942..e045079 100644
--- a/server-config/src/test/java/org/apache/directory/server/config/LdapServerConfigReaderTest.java
+++ b/server-config/src/test/java/org/apache/directory/server/config/LdapServerConfigReaderTest.java
@@ -37,7 +37,6 @@ import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.api.util.exception.Exceptions;
 import org.apache.directory.server.config.beans.ConfigBean;
 import org.apache.directory.server.config.beans.LdapServerBean;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.DnFactory;
 import org.apache.directory.server.core.partition.ldif.SingleFileLdifPartition;
 import org.apache.directory.server.core.shared.DefaultDnFactory;
@@ -62,7 +61,6 @@ public class LdapServerConfigReaderTest
 
     private static SchemaManager schemaManager;
     private static DnFactory dnFactory;
-    private static CacheService cacheService;
 
 
     @BeforeClass
@@ -99,10 +97,7 @@ public class LdapServerConfigReaderTest
             throw new Exception( "Schema load failed : " + Exceptions.printErrors( errors ) );
         }
 
-        cacheService = new CacheService();
-        cacheService.initialize( null );
-        dnFactory = new DefaultDnFactory( schemaManager, 
-            cacheService.getCache( "dnCache", String.class, Dn.class ) );
+        dnFactory = new DefaultDnFactory( schemaManager, 100 );
     }
 
 
@@ -118,7 +113,6 @@ public class LdapServerConfigReaderTest
         configPartition.setSuffixDn( new Dn( schemaManager, "ou=config" ) );
         configPartition.setSchemaManager( schemaManager );
 
-        configPartition.setCacheService( cacheService );
         configPartition.initialize();
         ConfigPartitionReader cpReader = new ConfigPartitionReader( configPartition );
 
diff --git a/server-integ/src/test/java/org/apache/directory/server/replication/ClientInitialRefreshIT.java b/server-integ/src/test/java/org/apache/directory/server/replication/ClientInitialRefreshIT.java
index bb811f9..ec76d4c 100644
--- a/server-integ/src/test/java/org/apache/directory/server/replication/ClientInitialRefreshIT.java
+++ b/server-integ/src/test/java/org/apache/directory/server/replication/ClientInitialRefreshIT.java
@@ -277,7 +277,7 @@ public class ClientInitialRefreshIT
                     directoryService.setSchemaManager( schemaManager );
                     ( ( MockSyncReplConsumer ) syncreplClient ).init( directoryService );
                     
-                    directoryService.setDnFactory( new DefaultDnFactory( schemaManager, null ) );
+                    directoryService.setDnFactory( new DefaultDnFactory( schemaManager, 100 ) );
                     syncreplClient.connect( true );
                     syncreplClient.startSync();
                 }
diff --git a/service/src/main/java/org/apache/directory/server/ApacheDsService.java b/service/src/main/java/org/apache/directory/server/ApacheDsService.java
index 2ae1b46..000fad3 100644
--- a/service/src/main/java/org/apache/directory/server/ApacheDsService.java
+++ b/service/src/main/java/org/apache/directory/server/ApacheDsService.java
@@ -60,11 +60,11 @@ import org.apache.directory.server.config.ConfigPartitionInitializer;
 import org.apache.directory.server.config.beans.ConfigBean;
 import org.apache.directory.server.config.beans.DirectoryServiceBean;
 import org.apache.directory.server.config.beans.HttpServerBean;
+import org.apache.directory.server.config.beans.JdbmPartitionBean;
 import org.apache.directory.server.config.beans.LdapServerBean;
 import org.apache.directory.server.config.beans.NtpServerBean;
 import org.apache.directory.server.config.builder.ServiceBuilder;
 import org.apache.directory.server.config.listener.ConfigChangeListener;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.CoreSession;
 import org.apache.directory.server.core.api.DirectoryService;
 import org.apache.directory.server.core.api.DnFactory;
@@ -74,6 +74,7 @@ import org.apache.directory.server.core.api.event.NotificationCriteria;
 import org.apache.directory.server.core.api.interceptor.context.ModifyOperationContext;
 import org.apache.directory.server.core.api.partition.Partition;
 import org.apache.directory.server.core.api.schema.SchemaPartition;
+import org.apache.directory.server.core.partition.impl.btree.AbstractBTreePartition;
 import org.apache.directory.server.core.partition.ldif.LdifPartition;
 import org.apache.directory.server.core.shared.DefaultDnFactory;
 import org.apache.directory.server.i18n.I18n;
@@ -174,14 +175,10 @@ public class ApacheDsService
 
         LOG.info( "using partition dir {}", partitionsDir.getAbsolutePath() );
 
-        CacheService cacheService = new CacheService();
-        cacheService.initialize( instanceLayout );
-
         initSchemaManager( instanceLayout );
-        DnFactory dnFactory = new DefaultDnFactory( schemaManager, 
-            cacheService.getCache( "dnCache", String.class, Dn.class ) );
-        initSchemaLdifPartition( instanceLayout, dnFactory );
-        initConfigPartition( instanceLayout, dnFactory, cacheService );
+        DnFactory bootstrapDnFactory = new DefaultDnFactory( schemaManager, 100 );
+        initSchemaLdifPartition( instanceLayout, bootstrapDnFactory );
+        initConfigPartition( instanceLayout, bootstrapDnFactory );
 
         // Read the configuration
         ConfigPartitionReader cpReader = new ConfigPartitionReader( configPartition );
@@ -190,9 +187,20 @@ public class ApacheDsService
 
         DirectoryServiceBean directoryServiceBean = configBean.getDirectoryServiceBean();
 
+        /*
+         * Calculate the DN cache size: from all defined partitions get the max cache size setting.
+         * Note: currently only JDBM partition beans have such a setting.
+         */
+        int dnCacheSize = directoryServiceBean.getPartitions().stream()
+            .filter( JdbmPartitionBean.class::isInstance )
+            .map( JdbmPartitionBean.class::cast )
+            .map( JdbmPartitionBean::getPartitionCacheSize )
+            .mapToInt( Integer::intValue )
+            .max().orElse( AbstractBTreePartition.DEFAULT_CACHE_SIZE );
+        DnFactory dnFactory = new DefaultDnFactory( schemaManager, dnCacheSize );
+
         // Initialize the DirectoryService now
-        DirectoryService directoryService = initDirectoryService( instanceLayout, directoryServiceBean, cacheService,
-            dnFactory );
+        DirectoryService directoryService = initDirectoryService( instanceLayout, directoryServiceBean, dnFactory );
 
         // start the LDAP server
         startLdap( directoryServiceBean.getLdapServerBean(), directoryService, startServers );
@@ -323,17 +331,17 @@ public class ApacheDsService
      * @param cacheService the Cache service
      * @throws Exception in case of any issues while extracting the schema
      */
-    private void initConfigPartition( InstanceLayout instanceLayout, DnFactory dnFactory, CacheService cacheService )
+    private void initConfigPartition( InstanceLayout instanceLayout, DnFactory dnFactory )
         throws Exception
     {
         ConfigPartitionInitializer initializer = new ConfigPartitionInitializer( instanceLayout, dnFactory,
-            cacheService, schemaManager );
+            schemaManager );
         configPartition = initializer.initConfigPartition();
     }
 
 
     private DirectoryService initDirectoryService( InstanceLayout instanceLayout,
-        DirectoryServiceBean directoryServiceBean, CacheService cacheService, DnFactory dnFactory ) throws Exception
+        DirectoryServiceBean directoryServiceBean, DnFactory dnFactory ) throws Exception
     {
         LOG.info( "Initializing the DirectoryService..." );
 
@@ -355,8 +363,6 @@ public class ApacheDsService
         // Store the default directories
         directoryService.setInstanceLayout( instanceLayout );
 
-        directoryService.setCacheService( cacheService );
-
         directoryService.startup();
 
         AttributeType ocAt = directoryService.getAtProvider().getObjectClass();
diff --git a/xdbm-partition/pom.xml b/xdbm-partition/pom.xml
index 84c156a..cd97ace 100644
--- a/xdbm-partition/pom.xml
+++ b/xdbm-partition/pom.xml
@@ -121,8 +121,7 @@
             </Export-Package>
             <Import-Package>
                 javax.naming,
-                org.ehcache;version=${ehcache.version},
-                org.ehcache.config;version=${ehcache.version},
+                com.github.benmanes.caffeine.cache;bundle-version=${caffeine.version},
                 org.apache.directory.api.i18n;version=${org.apache.directory.api.version},
                 org.apache.directory.api.ldap.model.constants;version=${org.apache.directory.api.version},
                 org.apache.directory.api.ldap.model.cursor;version=${org.apache.directory.api.version},
diff --git a/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java b/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
index 51fd374..5dcf74c 100644
--- a/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
+++ b/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
@@ -23,6 +23,7 @@ package org.apache.directory.server.core.partition.impl.btree;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.net.URI;
+import java.time.Duration;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -35,9 +36,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
-import org.ehcache.Cache;
-import org.ehcache.config.CacheConfiguration;
-
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.cursor.Cursor;
 import org.apache.directory.api.ldap.model.cursor.CursorException;
@@ -102,6 +100,9 @@ import org.apache.directory.server.xdbm.search.SearchEngine;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
+
 
 /**
  * An abstract {@link Partition} that uses general BTree operations.
@@ -129,10 +130,10 @@ public abstract class AbstractBTreePartition extends AbstractPartition implement
     protected int cacheSize = DEFAULT_CACHE_SIZE;
 
     /** The alias cache */
-    protected Cache< String, Dn > aliasCache;
+    protected Cache<String, Dn> aliasCache;
 
     /** The ParentIdAndRdn cache */
-    protected Cache< String, ParentIdAndRdn > piarCache;
+    protected Cache<String, ParentIdAndRdn> piarCache;
 
     /** true if we sync disks on every write operation */
     protected AtomicBoolean isSyncOnWrite = new AtomicBoolean( true );
@@ -539,8 +540,10 @@ public abstract class AbstractBTreePartition extends AbstractPartition implement
         // don't reset initialized flag
         initialized = false;
 
-        entryDnCache.clear();
-        
+        aliasCache.invalidateAll();
+        piarCache.invalidateAll();
+        entryDnCache.invalidateAll();
+
         MultiException errors = new MultiException( I18n.err( I18n.ERR_577 ) );
 
         for ( Index<?, String> index : userIndices.values() )
@@ -623,16 +626,14 @@ public abstract class AbstractBTreePartition extends AbstractPartition implement
         setupSystemIndices();
         setupUserIndices();
 
-        if ( cacheService != null )
-        {
-            aliasCache = cacheService.getCache( "alias", String.class, Dn.class );
-    
-            CacheConfiguration< String, Dn > aliasCacheConfig = aliasCache.getRuntimeConfiguration();
-            
-            piarCache = cacheService.getCache( "piar", String.class, ParentIdAndRdn.class );
-            
-            entryDnCache = cacheService.getCache( "entryDn", String.class, Dn.class );
-        }
+        aliasCache = Caffeine.newBuilder().maximumSize( cacheSize ).expireAfterAccess( Duration.ofMinutes( 20 ) )
+            .build();
+
+        piarCache = Caffeine.newBuilder().maximumSize( cacheSize * 3L )
+            .expireAfterAccess( Duration.ofMinutes( 20 ) ).build();
+
+        entryDnCache = Caffeine.newBuilder().maximumSize( cacheSize ).expireAfterAccess( Duration.ofMinutes( 20 ) )
+            .build();
     }
 
 
@@ -1138,7 +1139,7 @@ public abstract class AbstractBTreePartition extends AbstractPartition implement
 
                 ////dumpRdnIdx();
 
-                entryDnCache.remove( id );
+                entryDnCache.invalidate( id );
                 
                 Attribute csn = entry.get( entryCsnAT );
                 // can be null while doing subentry deletion
@@ -2009,7 +2010,7 @@ public abstract class AbstractBTreePartition extends AbstractPartition implement
         // Remove the EntryDN
         modifiedEntry.removeAttributes( entryDnAT );
 
-        entryDnCache.clear();
+        entryDnCache.invalidateAll();
         
         setContextCsn( modifiedEntry.get( entryCsnAT ).getString() );
 
@@ -2187,7 +2188,7 @@ public abstract class AbstractBTreePartition extends AbstractPartition implement
         modifiedEntry.add( ApacheSchemaConstants.ENTRY_PARENT_ID_OID, newParentId );
         
         // Doom the DN cache now
-        entryDnCache.clear();
+        entryDnCache.invalidateAll();
 
         setContextCsn( modifiedEntry.get( entryCsnAT ).getString() );
 
@@ -2519,7 +2520,7 @@ public abstract class AbstractBTreePartition extends AbstractPartition implement
 
         rdnIdx.add( partitionTxn, parentIdAndRdn, oldId );
 
-        entryDnCache.clear();
+        entryDnCache.invalidateAll();
         
         if ( isSyncOnWrite.get() )
         {
@@ -2617,7 +2618,7 @@ public abstract class AbstractBTreePartition extends AbstractPartition implement
 
             if ( entryDnCache != null )
             {
-                Dn cachedDn = entryDnCache.get( id );
+                Dn cachedDn = entryDnCache.getIfPresent( id );
                 
                 if ( cachedDn != null )
                 {
@@ -2631,7 +2632,7 @@ public abstract class AbstractBTreePartition extends AbstractPartition implement
             
                 if ( piarCache != null )
                 {
-                    cur = piarCache.get( parentId );
+                    cur = piarCache.getIfPresent( parentId );
                     
                     if ( cur == null )
                     {
@@ -3284,7 +3285,7 @@ public abstract class AbstractBTreePartition extends AbstractPartition implement
 
         if ( aliasCache != null )
         {
-            aliasCache.remove( aliasId );
+            aliasCache.invalidate( aliasId );
         }
     }
 
diff --git a/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java b/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
index 595f4ab..31184e9 100644
--- a/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
+++ b/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
@@ -30,8 +30,6 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.locks.ReadWriteLock;
 
-import org.ehcache.Cache;
-
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.entry.Entry;
 import org.apache.directory.api.ldap.model.entry.Modification;
@@ -43,6 +41,8 @@ import org.apache.directory.server.constants.ApacheSchemaConstants;
 import org.apache.directory.server.core.api.interceptor.context.ModDnAva;
 import org.apache.directory.server.core.api.partition.PartitionTxn;
 
+import com.github.benmanes.caffeine.cache.Cache;
+
 
 /**
  * Represents an entry store based on the Table, Index, and MasterTable
diff --git a/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/SubtreeScopeEvaluator.java b/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/SubtreeScopeEvaluator.java
index 67f3bdf..e88aab6 100644
--- a/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/SubtreeScopeEvaluator.java
+++ b/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/SubtreeScopeEvaluator.java
@@ -175,7 +175,7 @@ public class SubtreeScopeEvaluator implements Evaluator<ScopeNode>
          */
         if ( db.getAliasCache() != null )
         {
-            Dn dn = db.getAliasCache().get( id );
+            Dn dn = db.getAliasCache().getIfPresent( id );
             
             if ( dn != null )
             {
diff --git a/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java b/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
index 0918241..94ab6a4 100644
--- a/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
+++ b/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
@@ -155,7 +155,7 @@ public class DefaultSearchEngine implements SearchEngine
 
         if ( db.getAliasCache() != null )
         {
-            aliasedBase = db.getAliasCache().get( baseId );
+            aliasedBase = db.getAliasCache().getIfPresent( baseId );
         }
         else
         {
diff --git a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/PartitionTest.java b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/PartitionTest.java
index 11d8617..ac23382 100644
--- a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/PartitionTest.java
+++ b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/PartitionTest.java
@@ -54,7 +54,6 @@ import org.apache.directory.api.ldap.schema.loader.LdifSchemaLoader;
 import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.api.util.exception.Exceptions;
 import org.apache.directory.server.constants.ApacheSchemaConstants;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.DnFactory;
 import org.apache.directory.server.core.api.interceptor.context.ModDnAva;
 import org.apache.directory.server.core.api.partition.PartitionTxn;
@@ -91,8 +90,6 @@ public class PartitionTest
     /** The CN AttributType instance */
     private static AttributeType CN_AT;
 
-    private static CacheService cacheService;
-
     @BeforeClass
     public static void setup() throws Exception
     {
@@ -110,8 +107,6 @@ public class PartitionTest
         extractor.extractOrCopy( true );
         LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
 
-        cacheService = new CacheService();
-        cacheService.initialize( null );
         schemaManager = new DefaultSchemaManager( loader );
 
         boolean loaded = schemaManager.loadAllEnabled();
@@ -142,7 +137,6 @@ public class PartitionTest
         partition.addIndex( new AvlIndex<String>( SchemaConstants.CN_AT_OID ) );
         partition.setSuffixDn( new Dn( schemaManager, "o=Good Times Co." ) );
 
-        partition.setCacheService( cacheService );
         partition.initialize();
 
         StoreUtils.loadExampleData( partition, schemaManager );
diff --git a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java
index 2f03537..6ca7718 100644
--- a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java
+++ b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java
@@ -57,7 +57,6 @@ import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.api.util.exception.Exceptions;
 import org.apache.directory.server.constants.ApacheSchemaConstants;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.DnFactory;
 import org.apache.directory.server.core.api.entry.ClonedServerEntry;
 import org.apache.directory.server.core.api.interceptor.context.AddOperationContext;
@@ -101,7 +100,6 @@ public class AvlPartitionTest
     /** The ApacheAlias AttributeType instance */
     private static AttributeType APACHE_ALIAS_AT;
 
-    private static CacheService cacheService;
     private PartitionTxn txn;
 
 
@@ -123,10 +121,7 @@ public class AvlPartitionTest
         LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
 
         schemaManager = new DefaultSchemaManager( loader );
-        cacheService = new CacheService();
-        cacheService.initialize( null );
-        dnFactory = new DefaultDnFactory( schemaManager, 
-            cacheService.getCache( "dnCache", String.class, Dn.class ) );
+        dnFactory = new DefaultDnFactory( schemaManager, 100 );
 
         boolean loaded = schemaManager.loadAllEnabled();
 
@@ -158,7 +153,6 @@ public class AvlPartitionTest
         partition.addIndex( new AvlIndex<String>( SchemaConstants.UID_AT_OID ) );
         partition.setSuffixDn( new Dn( schemaManager, "o=Good Times Co." ) );
 
-        partition.setCacheService( cacheService );
         partition.initialize();
 
         StoreUtils.loadExampleData( partition, schemaManager );
diff --git a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java
index 8ebc3b4..1c501d7 100644
--- a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java
+++ b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java
@@ -42,7 +42,6 @@ import org.apache.directory.api.ldap.schema.loader.LdifSchemaLoader;
 import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.api.util.exception.Exceptions;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.LdapPrincipal;
 import org.apache.directory.server.core.api.MockCoreSession;
 import org.apache.directory.server.core.api.MockDirectoryService;
@@ -70,7 +69,6 @@ public class AndCursorTest extends AbstractCursorTest
     private static final Logger LOG = LoggerFactory.getLogger( AndCursorTest.class );
 
     File wkdir;
-    private static CacheService cacheService;
 
 
     @BeforeClass
@@ -105,9 +103,6 @@ public class AndCursorTest extends AbstractCursorTest
         {
             fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
         }
-
-        cacheService = new CacheService();
-        cacheService.initialize( null );
     }
 
 
@@ -134,7 +129,6 @@ public class AndCursorTest extends AbstractCursorTest
         store.addIndex( new AvlIndex<String>( SchemaConstants.OU_AT_OID ) );
         store.addIndex( new AvlIndex<String>( SchemaConstants.CN_AT_OID ) );
         ( ( Partition ) store ).setSuffixDn( new Dn( schemaManager, "o=Good Times Co." ) );
-        ( ( Partition ) store ).setCacheService( cacheService );
         ( ( Partition ) store ).initialize();
 
         StoreUtils.loadExampleData( store, schemaManager );
diff --git a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/EqualityTest.java b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/EqualityTest.java
index b737b5a..45c03a0 100644
--- a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/EqualityTest.java
+++ b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/EqualityTest.java
@@ -46,7 +46,6 @@ import org.apache.directory.api.ldap.schema.loader.LdifSchemaLoader;
 import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.api.util.exception.Exceptions;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.DnFactory;
 import org.apache.directory.server.core.api.partition.Partition;
 import org.apache.directory.server.core.api.partition.PartitionTxn;
@@ -81,7 +80,6 @@ public class EqualityTest
     Store store;
     static SchemaManager schemaManager = null;
     private static DnFactory dnFactory;
-    private static CacheService cacheService;
 
 
     @BeforeClass
@@ -116,10 +114,7 @@ public class EqualityTest
             fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
         }
 
-        cacheService = new CacheService();
-        cacheService.initialize( null );
-        dnFactory = new DefaultDnFactory( schemaManager, 
-            cacheService.getCache( "dnCache", String.class, Dn.class ) );
+        dnFactory = new DefaultDnFactory( schemaManager, 100 );
     }
 
 
@@ -144,7 +139,6 @@ public class EqualityTest
         store.addIndex( new AvlIndex<String>( SchemaConstants.OU_AT_OID ) );
         store.addIndex( new AvlIndex<String>( SchemaConstants.CN_AT_OID ) );
         ( ( Partition ) store ).setSuffixDn( new Dn( schemaManager, "o=Good Times Co." ) );
-        ( ( Partition ) store ).setCacheService( cacheService );
         ( ( Partition ) store ).initialize();
 
         StoreUtils.loadExampleData( store, schemaManager );
diff --git a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqNotIndexedTest.java b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqNotIndexedTest.java
index de81f9d..646f445 100644
--- a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqNotIndexedTest.java
+++ b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqNotIndexedTest.java
@@ -56,7 +56,6 @@ import org.apache.directory.api.ldap.schema.loader.LdifSchemaLoader;
 import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.api.util.exception.Exceptions;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.DnFactory;
 import org.apache.directory.server.core.api.interceptor.context.AddOperationContext;
 import org.apache.directory.server.core.api.partition.Partition;
@@ -90,7 +89,6 @@ public class GreaterEqNotIndexedTest
     Store store;
     static SchemaManager schemaManager = null;
     private static DnFactory dnFactory;
-    private static CacheService cacheService;
 
 
     @BeforeClass
@@ -126,10 +124,7 @@ public class GreaterEqNotIndexedTest
             fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
         }
 
-        cacheService = new CacheService();
-        cacheService.initialize( null );
-        dnFactory = new DefaultDnFactory( schemaManager, 
-            cacheService.getCache( "dnCache", String.class, Dn.class ) );
+        dnFactory = new DefaultDnFactory( schemaManager, 100 );
     }
 
 
@@ -154,7 +149,6 @@ public class GreaterEqNotIndexedTest
         store.addIndex( new AvlIndex<String>( SchemaConstants.OU_AT_OID ) );
         store.addIndex( new AvlIndex<String>( SchemaConstants.CN_AT_OID ) );
         ( ( Partition ) store ).setSuffixDn( new Dn( schemaManager, "o=Good Times Co." ) );
-        ( ( Partition ) store ).setCacheService( cacheService );
         ( ( Partition ) store ).initialize();
 
         StoreUtils.loadExampleData( store, schemaManager );
diff --git a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java
index d2d7bd9..067cace 100644
--- a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java
+++ b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java
@@ -56,7 +56,6 @@ import org.apache.directory.api.ldap.schema.loader.LdifSchemaLoader;
 import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.api.util.exception.Exceptions;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.DnFactory;
 import org.apache.directory.server.core.api.interceptor.context.AddOperationContext;
 import org.apache.directory.server.core.api.partition.Partition;
@@ -90,7 +89,6 @@ public class GreaterEqTest
     Store store;
     static SchemaManager schemaManager = null;
     private static DnFactory dnFactory;
-    private static CacheService cacheService;
 
     @BeforeClass
     public static void setup() throws Exception
@@ -125,11 +123,7 @@ public class GreaterEqTest
             fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
         }
 
-        cacheService = new CacheService();
-        cacheService.initialize( null );
-        dnFactory = new DefaultDnFactory( schemaManager, 
-            cacheService.getCache( "dnCache", String.class, Dn.class ) );
-
+        dnFactory = new DefaultDnFactory( schemaManager, 100 );
     }
 
 
@@ -155,7 +149,6 @@ public class GreaterEqTest
         store.addIndex( new AvlIndex<String>( SchemaConstants.CN_AT_OID ) );
         store.addIndex( new AvlIndex<String>( StoreUtils.TEST_INT_OID ) );
         ( ( Partition ) store ).setSuffixDn( new Dn( schemaManager, "o=Good Times Co." ) );
-        ( ( Partition ) store ).setCacheService( cacheService );
         ( ( Partition ) store ).initialize();
 
         StoreUtils.loadExampleData( store, schemaManager );
diff --git a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java
index 8e418ff..25d6bd5 100644
--- a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java
+++ b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java
@@ -56,7 +56,6 @@ import org.apache.directory.api.ldap.schema.loader.LdifSchemaLoader;
 import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.api.util.exception.Exceptions;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.DnFactory;
 import org.apache.directory.server.core.api.interceptor.context.AddOperationContext;
 import org.apache.directory.server.core.api.partition.Partition;
@@ -90,7 +89,6 @@ public class LessEqTest
     Store store;
     static SchemaManager schemaManager = null;
     private static DnFactory dnFactory;
-    private static CacheService cacheService;
 
 
     @BeforeClass
@@ -126,11 +124,7 @@ public class LessEqTest
             fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
         }
 
-        cacheService = new CacheService();
-        cacheService.initialize( null );
-        dnFactory = new DefaultDnFactory( schemaManager, 
-            cacheService.getCache( "dnCache", String.class, Dn.class ) );
-
+        dnFactory = new DefaultDnFactory( schemaManager, 100 );
     }
 
 
@@ -156,7 +150,6 @@ public class LessEqTest
         store.addIndex( new AvlIndex<String>( SchemaConstants.CN_AT_OID ) );
         store.addIndex( new AvlIndex<String>( StoreUtils.TEST_INT_OID ) );
         ( ( Partition ) store ).setSuffixDn( new Dn( schemaManager, "o=Good Times Co." ) );
-        ( ( Partition ) store ).setCacheService( cacheService );
         ( ( Partition ) store ).initialize();
 
         StoreUtils.loadExampleData( store, schemaManager );
diff --git a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java
index c7fe920..8550662 100644
--- a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java
+++ b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java
@@ -46,7 +46,6 @@ import org.apache.directory.api.ldap.schema.loader.LdifSchemaLoader;
 import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.api.util.exception.Exceptions;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.LdapPrincipal;
 import org.apache.directory.server.core.api.MockCoreSession;
 import org.apache.directory.server.core.api.MockDirectoryService;
@@ -78,7 +77,6 @@ public class NestedFilterTest extends AbstractCursorTest
     static SchemaManager schemaManager = null;
     Optimizer optimizer;
     static FilterNormalizingVisitor visitor;
-    private static CacheService cacheService;
 
 
     @BeforeClass
@@ -117,8 +115,6 @@ public class NestedFilterTest extends AbstractCursorTest
         NameComponentNormalizer ncn = new ConcreteNameComponentNormalizer( schemaManager );
         visitor = new FilterNormalizingVisitor( ncn, schemaManager );
 
-        cacheService = new CacheService();
-        cacheService.initialize( null );
     }
 
 
@@ -145,7 +141,6 @@ public class NestedFilterTest extends AbstractCursorTest
         store.addIndex( new AvlIndex<String>( SchemaConstants.OU_AT_OID ) );
         store.addIndex( new AvlIndex<String>( SchemaConstants.CN_AT_OID ) );
         ( ( Partition ) store ).setSuffixDn( new Dn( schemaManager, "o=Good Times Co." ) );
-        ( ( Partition ) store ).setCacheService( cacheService );
         ( ( Partition ) store ).initialize();
 
         StoreUtils.loadExampleData( store, schemaManager );
diff --git a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java
index 7de3926..5555d6d 100644
--- a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java
+++ b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java
@@ -47,7 +47,6 @@ import org.apache.directory.api.ldap.schema.loader.LdifSchemaLoader;
 import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.api.util.exception.Exceptions;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.LdapPrincipal;
 import org.apache.directory.server.core.api.MockCoreSession;
 import org.apache.directory.server.core.api.MockDirectoryService;
@@ -83,7 +82,6 @@ public class NotCursorTest extends AbstractCursorTest
 
     File wkdir;
     static SchemaManager schemaManager = null;
-    private static CacheService cacheService;
 
 
     @BeforeClass
@@ -119,8 +117,6 @@ public class NotCursorTest extends AbstractCursorTest
             fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
         }
 
-        cacheService = new CacheService();
-        cacheService.initialize( null );
     }
 
 
@@ -147,7 +143,6 @@ public class NotCursorTest extends AbstractCursorTest
         store.addIndex( new AvlIndex<String>( SchemaConstants.OU_AT_OID ) );
         store.addIndex( new AvlIndex<String>( SchemaConstants.CN_AT_OID ) );
         ( ( Partition ) store ).setSuffixDn( new Dn( schemaManager, "o=Good Times Co." ) );
-        ( ( Partition ) store ).setCacheService( cacheService );
         ( ( Partition ) store ).initialize();
 
         StoreUtils.loadExampleData( store, schemaManager );
diff --git a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OrCursorTest.java b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OrCursorTest.java
index 57e1954..4a73ace 100644
--- a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OrCursorTest.java
+++ b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OrCursorTest.java
@@ -47,7 +47,6 @@ import org.apache.directory.api.ldap.schema.loader.LdifSchemaLoader;
 import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.api.util.exception.Exceptions;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.LdapPrincipal;
 import org.apache.directory.server.core.api.MockCoreSession;
 import org.apache.directory.server.core.api.MockDirectoryService;
@@ -86,7 +85,6 @@ public class OrCursorTest extends AbstractCursorTest
 
     File wkdir;
     static SchemaManager schemaManager = null;
-    private static CacheService cacheService;
 
 
     @BeforeClass
@@ -121,8 +119,6 @@ public class OrCursorTest extends AbstractCursorTest
             fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
         }
 
-        cacheService = new CacheService();
-        cacheService.initialize( null );
     }
 
 
@@ -149,7 +145,6 @@ public class OrCursorTest extends AbstractCursorTest
         store.addIndex( new AvlIndex<String>( SchemaConstants.OU_AT_OID ) );
         store.addIndex( new AvlIndex<String>( SchemaConstants.CN_AT_OID ) );
         ( ( Partition ) store ).setSuffixDn( new Dn( schemaManager, "o=Good Times Co." ) );
-        ( ( Partition ) store ).setCacheService( cacheService );
         ( ( Partition ) store ).initialize();
 
         StoreUtils.loadExampleData( store, schemaManager );
diff --git a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java
index 4cc8132..76bd447 100644
--- a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java
+++ b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java
@@ -44,7 +44,6 @@ import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.api.util.exception.Exceptions;
 import org.apache.directory.server.constants.ApacheSchemaConstants;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.DnFactory;
 import org.apache.directory.server.core.api.partition.Partition;
 import org.apache.directory.server.core.api.partition.PartitionTxn;
@@ -77,7 +76,6 @@ public class PresenceTest
     Store store;
     static SchemaManager schemaManager = null;
     private static DnFactory dnFactory;
-    private static CacheService cacheService;
     private static String NORMALIZED_CN_OID;
 
 
@@ -113,13 +111,10 @@ public class PresenceTest
             fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
         }
 
-        cacheService = new CacheService();
-        cacheService.initialize( null );
-        dnFactory = new DefaultDnFactory( schemaManager, 
-            cacheService.getCache( "dnCache", String.class, Dn.class ) );
+        dnFactory = new DefaultDnFactory( schemaManager, 100 );
 
-        
-        NORMALIZED_CN_OID = schemaManager.getAttributeType( ApacheSchemaConstants.APACHE_PRESENCE_AT ).getEquality().getNormalizer().normalize( SchemaConstants.CN_AT_OID );
+        NORMALIZED_CN_OID = schemaManager.getAttributeType( ApacheSchemaConstants.APACHE_PRESENCE_AT ).getEquality()
+            .getNormalizer().normalize( SchemaConstants.CN_AT_OID );
     }
 
 
@@ -144,7 +139,6 @@ public class PresenceTest
         store.addIndex( new AvlIndex<String>( SchemaConstants.OU_AT_OID, false ) );
         store.addIndex( new AvlIndex<String>( SchemaConstants.CN_AT_OID, false ) );
         ( ( Partition ) store ).setSuffixDn( new Dn( schemaManager, "o=Good Times Co." ) );
-        ( ( Partition ) store ).setCacheService( cacheService );
         ( ( Partition ) store ).initialize();
 
         ( ( Partition ) store ).initialize();
diff --git a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubstringTest.java b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubstringTest.java
index d9ad172..aed33e6 100644
--- a/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubstringTest.java
+++ b/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubstringTest.java
@@ -39,7 +39,6 @@ import org.apache.directory.api.ldap.schema.loader.LdifSchemaLoader;
 import org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.api.util.exception.Exceptions;
-import org.apache.directory.server.core.api.CacheService;
 import org.apache.directory.server.core.api.DnFactory;
 import org.apache.directory.server.core.api.partition.Partition;
 import org.apache.directory.server.core.api.partition.PartitionTxn;
@@ -72,7 +71,6 @@ public class SubstringTest
     Store store;
     static SchemaManager schemaManager = null;
     private static DnFactory dnFactory;
-    private static CacheService cacheService;
 
 
     @BeforeClass
@@ -107,11 +105,7 @@ public class SubstringTest
             fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
         }
 
-        cacheService = new CacheService();
-        cacheService.initialize( null );
-        dnFactory = new DefaultDnFactory( schemaManager, 
-            cacheService.getCache( "dnCache", String.class, Dn.class ) );
-
+        dnFactory = new DefaultDnFactory( schemaManager, 100 );
     }
 
 
@@ -139,7 +133,6 @@ public class SubstringTest
         Dn suffixDn = new Dn( schemaManager, "o=Good Times Co." );
         ( ( Partition ) store ).setSuffixDn( suffixDn );
 
-        ( ( Partition ) store ).setCacheService( cacheService );
         ( ( Partition ) store ).initialize();
 
         StoreUtils.loadExampleData( store, schemaManager );