//package com.cache;
//
//
//
//import java.io.IOException;
//import java.io.ObjectOutputStream;
//import java.io.OutputStream;
//import java.util.ArrayList;
//import java.util.Collection;
//import java.util.HashMap;
//import java.util.HashSet;
//import java.util.Iterator;
//import java.util.Map;
//import java.util.NoSuchElementException;
//import java.util.Set;
//
//import org.jivesoftware.util.LinkedListNode;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
///**
// * Default, non-distributed implementation of the Cache interface.
// * The algorithm for cache is as follows: a HashMap is maintained for fast
// * object lookup. Two linked lists are maintained: one keeps objects in the
// * order they are accessed from cache, the other keeps objects in the order
// * they were originally added to cache. When objects are added to cache, they
// * are first wrapped by a CacheObject which maintains the following pieces
// * of information:<ul>
// *
// * <li> The size of the object (in bytes).
// * <li> A pointer to the node in the linked list that maintains accessed
// * order for the object. Keeping a reference to the node lets us avoid
// * linear scans of the linked list.
// * <li> A pointer to the node in the linked list that maintains the age
// * of the object in cache. Keeping a reference to the node lets us avoid
// * linear scans of the linked list.</ul><p>
// *
// * To get an object from cache, a hash lookup is performed to get a reference
// * to the CacheObject that wraps the real object we are looking for.
// * The object is subsequently moved to the front of the accessed linked list
// * and any necessary cache cleanups are performed. Cache deletion and expiration
// * is performed as needed.
// *
// * @author Matt Tucker
// */
//public class DefaultCache<K, V> implements Cache<K, V> {
//
// private static final Logger Log = LoggerFactory.getLogger(DefaultCache.class);
//
// /**
// * The map the keys and values are stored in.
// */
// protected Map<K, DefaultCache.CacheObject<V>> map;
//
// /**
// * Linked list to maintain order that cache objects are accessed
// * in, most used to least used.
// */
// protected org.jivesoftware.util.LinkedList lastAccessedList;
//
// /**
// * Linked list to maintain time that cache objects were initially added
// * to the cache, most recently added to oldest added.
// */
// protected org.jivesoftware.util.LinkedList ageList;
//
// /**
// * Maximum size in bytes that the cache can grow to.
// */
// private long maxCacheSize;
//
// /**
// * Maintains the current size of the cache in bytes.
// */
// private int cacheSize = 0;
//
// /**
// * Maximum length of time objects can exist in cache before expiring.
// */
// protected long maxLifetime;
//
// /**
// * Maintain the number of cache hits and misses. A cache hit occurs every
// * time the get method is called and the cache contains the requested
// * object. A cache miss represents the opposite occurence.<p>
// *
// * Keeping track of cache hits and misses lets one measure how efficient
// * the cache is; the higher the percentage of hits, the more efficient.
// */
// protected long cacheHits, cacheMisses = 0L;
//
// /**
// * The name of the cache.
// */
// private String name;
//
// /**
// * Create a new default cache and specify the maximum size of for the cache in
// * bytes, and the maximum lifetime of objects.
// *
// * @param name a name for the cache.
// * @param maxSize the maximum size of the cache in bytes. -1 means the cache
// * has no max size.
// * @param maxLifetime the maximum amount of time objects can exist in
// * cache before being deleted. -1 means objects never expire.
// */
// public DefaultCache(String name, long maxSize, long maxLifetime) {
// this.name = name;
// this.maxCacheSize = maxSize;
// this.maxLifetime = maxLifetime;
//
// // Our primary data structure is a HashMap. The default capacity of 11
// // is too small in almost all cases, so we set it bigger.
// map = new HashMap<K, CacheObject<V>>(103);
//
// lastAccessedList = new org.jivesoftware.util.LinkedList();
// ageList = new org.jivesoftware.util.LinkedList();
// }
//
// public synchronized V put(K key, V value) {
// // Delete an old entry if it exists.
// V answer = remove(key);
//
// int objectSize = calculateSize(value);
//
// // If the object is bigger than the entire cache, simply don't add it.
// if (maxCacheSize > 0 && objectSize > maxCacheSize * .90) {
// Log.warn("Cache: " + name + " -- object with key " + key +
// " is too large to fit in cache. Size is " + objectSize);
// return value;
// }
// cacheSize += objectSize;
// DefaultCache.CacheObject<V> cacheObject = new DefaultCache.CacheObject<V>(value, objectSize);
// map.put(key, cacheObject);
// // Make an entry into the cache order list.
// LinkedListNode lastAccessedNode = lastAccessedList.addFirst(key);
// // Store the cache order list entry so that we can get back to it
// // during later lookups.
// cacheObject.lastAccessedListNode = lastAccessedNode;
// // Add the object to the age list
// LinkedListNode ageNode = ageList.addFirst(key);
// // We make an explicit call to currentTimeMillis() so that total accuracy
// // of lifetime calculations is better than one second.
// ageNode.timestamp = System.currentTimeMillis();
// cacheObject.ageListNode = ageNode;
//
// // If cache is too full, remove least used cache entries until it is
// // not too full.
// cullCache();
//
// return answer;
// }
//
// public synchronized V get(Object key) {
// // First, clear all entries that have been in cache longer than the
// // maximum defined age.
// deleteExpiredEntries();
//
// DefaultCache.CacheObject<V> cacheObject = map.get(key);
// if (cacheObject == null) {
// // The object didn't exist in cache, so increment cache misses.
// cacheMisses++;
// return null;
// }
//
// // The object exists in cache, so increment cache hits. Also, increment
// // the object's read count.
// cacheHits++;
// cacheObject.readCount++;
//
// // Remove the object from it's current place in the cache order list,
// // and re-insert it at the front of the list.
// cacheObject.lastAccessedListNode.remove();
// lastAccessedList.addFirst(cacheObject.lastAccessedListNode);
//
// return cacheObject.object;
// }
//
// public synchronized V remove(Object key) {
// DefaultCache.CacheObject<V> cacheObject = map.get(key);
// // If the object is not in cache, stop trying to remove it.
// if (cacheObject == null) {
// return null;
// }
// // remove from the hash map
// map.remove(key);
// // remove from the cache order list
// cacheObject.lastAccessedListNode.remove();
// cacheObject.ageListNode.remove();
// // remove references to linked list nodes
// cacheObject.ageListNode = null;
// cacheObject.lastAccessedListNode = null;
// // removed the object, so subtract its size from the total.
// cacheSize -= cacheObject.size;
// return cacheObject.object;
// }
//
// public synchronized void clear() {
// Object[] keys = map.keySet().toArray();
// for (int i = 0; i < keys.length; i++) {
// remove(key
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
共 254 条
- 1
- 2
- 3
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
- 乔哥2013-08-23资料不错,最近正研究反推呢!
![avatar](https://profile-avatar.csdnimg.cn/101f8ed12d5143fc92aefb1a0f6b783d_thinks_quiet.jpg!1)
![avatar-vip](https://csdnimg.cn/release/downloadcmsfe/public/img/user-vip.1c89f3c5.png)
Thinks_quiet
- 粉丝: 6
- 资源: 28
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)