org.ligoj.app.plugin.id.resource.IdCache Maven / Gradle / Ivy
/*
* Licensed under MIT (https://github.com/ligoj/ligoj/blob/master/LICENSE)
*/
package org.ligoj.app.plugin.id.resource;
import java.util.function.Function;
import javax.cache.expiry.Duration;
import javax.cache.expiry.ModifiedExpiryPolicy;
import org.ligoj.bootstrap.resource.system.cache.CacheManagerAware;
import org.springframework.stereotype.Component;
import com.hazelcast.cache.HazelcastCacheManager;
import com.hazelcast.config.CacheConfig;
/**
* Cache configuration for IAM.
*/
@Component
public class IdCache implements CacheManagerAware {
@Override
public void onCreate(final HazelcastCacheManager cacheManager, final Function> provider) {
cacheManager.createCache("container-scopes", provider.apply("container-scopes"));
final var isAdmin = provider.apply("user-is-admin");
isAdmin.setExpiryPolicyFactory(ModifiedExpiryPolicy.factoryOf(Duration.ONE_MINUTE));
cacheManager.createCache("user-is-admin", isAdmin);
cacheManager.createCache("id-configuration", provider.apply("id-configuration"));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy