@Override
    public RegisteredService getRegisteredServiceFromCacheByPredicate(
        final RegisteredService service,
        final Predicate<DistributedCacheObject<RegisteredService>> predicate,
        final ServiceRegistry serviceRegistry) {
        val result = this.distributedCacheManager.find(predicate);
        if (result.isPresent()) {
            val item = result.get();
            val value = item.getValue();
            LOGGER.debug("Located cache entry [{}] in service registry cache [{}]", item, this.distributedCacheManager.getName());
            if (isRegisteredServiceMarkedAsDeletedInCache(item)) {
                LOGGER.debug("Service found in the cache [{}] is marked as a deleted service. CAS will update the service registry "
                             + "of this CAS node to remove the local service, if found", value);
                serviceRegistry.delete(value);
                this.distributedCacheManager.remove(value, item, true);
                return service;
            }

            if (service == null) {
                LOGGER.debug("Service is in not found in the local service registry for this CAS node. CAS will use the cache entry [{}] instead "
                             + "and will update the service registry of this CAS node with the cache entry for future look-ups", value);
                saveRegisteredServiceIfNecessary(serviceRegistry, value);
                return value;
            }
            LOGGER.debug("Service definition cache entry [{}] carries the timestamp [{}]", value, item.getTimestamp());
            if (value.equals(service)) {
                LOGGER.debug("Service definition cache entry is the same as service definition found locally");
                return service;
            }
            LOGGER.debug("Service definition found in the cache [{}] is more recent than its counterpart on this CAS node. CAS will "
                         + "use the cache entry and update the service registry of this CAS node with the cache entry for future look-ups", value);

            saveRegisteredServiceIfNecessary(serviceRegistry, value);

            return value;
        }
        LOGGER.debug("Requested service definition is not found in the replication cache");
        if (service != null) {
            LOGGER.debug("Attempting to update replication cache with service [{}]", service);
            val item = DistributedCacheObject.<RegisteredService>builder()
                .value(service)
                .publisherIdentifier(publisherIdentifier)
                .build();
            this.distributedCacheManager.set(service, item, true);
        }
        return service;
    }
This is {@link DefaultRegisteredServiceReplicationStrategy}.

@author Misagh Moayyed
@since 5.2.0
core/cas-server-core-services-registry/src/main/java/org/apereo/cas/services/replication/DefaultRegisteredServiceReplicationStrategy.java