All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gregmarut.commons.filecache.InMemoryCache Maven / Gradle / Ivy

There is a newer version: 0.6
Show newest version
/*******************************************************************************
 * 
 * Copyright (c) 2015 Greg Marut.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     Greg Marut - initial API and implementation
 * 
******************************************************************************/ package com.gregmarut.commons.filecache; import java.util.HashMap; import java.util.Map; public class InMemoryCache implements FileCache { // holds the map that will contain the in-memory cache private final Map cache; public InMemoryCache() { cache = new HashMap(); } @Override public void delete(String relativePath) { cache.remove(relativePath); } @Override public byte[] load(String relativePath) { return cache.get(relativePath); } @Override public void save(String relativePath, byte[] data) { cache.put(relativePath, data); } @Override public boolean exists(String relativePath) { return cache.containsKey(relativePath); } @Override public void clear() { cache.clear(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy