org.appops.cache.util.GuavaMetricUtils Maven / Gradle / Ivy
/*
* AppOps is a Java framework to develop, deploy microservices with ease and is available for free
* and common use developed by AinoSoft ( www.ainosoft.com )
*
* AppOps and AinoSoft are registered trademarks of Aino Softwares private limited, India.
*
* Copyright (C) <2016>
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version along with applicable additional terms as
* provisioned by GPL 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License and applicable additional terms
* along with this program.
*
* If not, see and
*/
package org.appops.cache.util;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import java.util.HashMap;
import java.util.concurrent.ConcurrentMap;
/**
* Utility class which facilitates operations on Google Guava cache.
*
* @author suraj
* @version $Id: $Id
*/
public class GuavaMetricUtils {
private Cache cache;
/**
* Constructor for GuavaMetricUtils.
*/
public GuavaMetricUtils() {
cache = CacheBuilder.newBuilder().build();
}
/**
* put.
*
* @param key a {@link java.lang.String} object.
* @param value a {@link java.lang.String} object.
*/
public void put(String key, String value) {
this.cache.put(key, value);
}
/**
* Getter for the field cache
.
*
* @return a {@link com.google.common.cache.Cache} object.
*/
public Cache getCache() {
return cache;
}
/**
* Setter for the field cache
.
*
* @param cache a {@link com.google.common.cache.Cache} object.
*/
public void setCache(Cache cache) {
this.cache = cache;
}
/**
* getIfPresent.
*
* @param key a {@link java.lang.String} object.
* @return a {@link java.lang.String} object.
*/
public String getIfPresent(String key) {
return this.cache.getIfPresent(key);
}
/**
* putAll.
*
* @param map a {@link java.util.HashMap} object.
*/
public void putAll(HashMap map) {
this.cache.putAll(map);
}
/**
* invalidate.
*
* @param key a {@link java.lang.String} object.
*/
public void invalidate(String key) {
this.cache.invalidate(key);
}
/**
* asMap.
*
* @return a {@link java.util.concurrent.ConcurrentMap} object.
*/
public ConcurrentMap asMap() {
return this.cache.asMap();
}
/**
* invalidateAll.
*
* @param keys a {@link java.lang.Iterable} object.
*/
public void invalidateAll(Iterable keys) {
this.cache.invalidateAll(keys);
}
/**
* invalidateAll.
*/
public void invalidateAll() {
this.cache.invalidateAll();
}
/**
* cleanUp.
*/
public void cleanUp() {
this.cache.cleanUp();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy