io.kestros.commons.osgiserviceutils.services.cache.CacheService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kestros-osgi-service-utils Show documentation
Show all versions of kestros-osgi-service-utils Show documentation
Foundational and utility logic for building OSGI Services on Kestros/Sling
instances.
/*
* 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 io.kestros.commons.osgiserviceutils.services.cache;
import io.kestros.commons.osgiserviceutils.exceptions.CachePurgeException;
import io.kestros.commons.osgiserviceutils.services.ManagedService;
import java.io.Serializable;
import java.util.Date;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.apache.sling.api.resource.ResourceResolver;
/**
* Manages the managing, building, purging and retrieval of Cached values.
*/
public interface CacheService extends ManagedService {
/**
* Enables cache service to allow caching and value retrieval. Purges caches before enabling.
*
* @param resourceResolver ResourceResolver for user performing cache purge.
* @throws CachePurgeException CacheService failed to purge all cached values.
*/
void enable(@Nonnull final ResourceResolver resourceResolver) throws CachePurgeException;
/**
* Disables cache service to prevent caching and value retrieval. Purges caches disabling.
*
* @param resourceResolver ResourceResolver for user performing cache purge.
* @throws CachePurgeException CacheService failed to purge all cached values.
*/
void disable(@Nonnull final ResourceResolver resourceResolver) throws CachePurgeException;
/**
* Whether the cache service is enabled.
*
* @return Whether the cache service is enabled.
*/
boolean isLive();
/**
* Date the last purgeAll was performed.
*
* @return Date the last purgeAll was performed.
*/
@Nullable
Date getLastPurged();
/**
* UserID that performed the last purgeAll.
*
* @return UserID that performed the last purgeAll.
*/
@Nullable
String getLastPurgedBy();
/**
* Purges entire cache.
*
* @param resourceResolver ResourceResolver for user performing cache purge.
* @throws CachePurgeException CacheService failed to purge all cached values.
*/
void purgeAll(@Nonnull final ResourceResolver resourceResolver) throws CachePurgeException;
}