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

org.xson.web.cache.LocalCache Maven / Gradle / Ivy

Go to download

xco-web is an easy to use control layer framework, is part of the SOA system, using xml language to describe the controller.

The newest version!
package org.xson.web.cache;

import java.util.HashMap;
import java.util.Map;

import org.xson.web.XcoWebException;

/**
 * 底层Cache
 */
public class LocalCache extends AbstractCache {

	private String				id;

	private Map	cache	= new HashMap(1024);

	public LocalCache(String id) {
		this.id = id;
	}

	public String getId() {
		return id;
	}

	public int getSize() {
		return cache.size();
	}

	@Override
	public void putObject(Object key, Object value, Integer time) {
		cache.put(key, value);
	}

	public Object getObject(Object key) {
		return cache.get(key);
	}

	public Object removeObject(Object key) {
		return cache.remove(key);
	}

	public void clear() {
		cache.clear();
	}

	public boolean equals(Object o) {
		if (getId() == null) {
			throw new XcoWebException("Cache instances require an ID.");
		}
		if (this == o) {
			return true;
		}

		if (!(o instanceof ICache)) {
			return false;
		}

		ICache otherCache = (ICache) o;
		return getId().equals(otherCache.getId());
	}

	public int hashCode() {
		if (getId() == null) {
			throw new XcoWebException("Cache instances require an ID.");
		}
		return getId().hashCode();
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy