memorycache.java
来自「Sony Ericsson手机上的Facebook客户端全套代码」· Java 代码 · 共 111 行
JAVA
111 行
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3)
// Source File Name: MemoryCache.java
package se.southend.drops.cache;
import java.util.Hashtable;
import java.util.Vector;
// Referenced classes of package se.southend.drops.cache:
// Cache, CacheInfo
public class MemoryCache
implements Cache
{
private class Entry
{
CacheInfo info;
byte data[];
Entry(CacheInfo info, byte data[])
{
this.info = info;
this.data = data;
}
}
public MemoryCache()
{
cache = new Hashtable();
keys = new Vector();
}
public static MemoryCache getInstance()
{
if(instance == null)
instance = new MemoryCache();
return instance;
}
public byte[] get(String key)
{
Entry entry = (Entry)cache.get(key);
return entry != null ? entry.data : null;
}
public CacheInfo getInfo(String key)
{
Entry entry = (Entry)cache.get(key);
return entry != null ? entry.info : null;
}
public void put(String key, byte data[])
{
put(key, null, data);
}
public void put(String key, CacheInfo info, byte data[])
{
Entry entry = new Entry(info, data);
size += data.length;
cache.put(key, entry);
keys.addElement(key);
}
public void remove(String key)
{
size -= ((byte[])((Entry)cache.get(key)).data).length;
cache.remove(key);
keys.removeElement(key);
}
public void empty()
{
size = 0;
cache.clear();
keys.removeAllElements();
}
public boolean contains(String key)
{
return cache.containsKey(key);
}
public String[] contents()
{
String contents[] = new String[keys.size()];
keys.copyInto(contents);
return contents;
}
public int size()
{
return size;
}
public void close()
{
cache.clear();
keys.removeAllElements();
}
private static MemoryCache instance;
private Hashtable cache;
private Vector keys;
private int size;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?