分享一个LRUMap的实现――来自apache common-collections框架 (三)

2014-11-24 08:12:18 · 作者: · 浏览: 3
protected void doWriteObject(ObjectOutputStream out) throws IOException {
419: out.writeInt(maxSize);
420: super.doWriteObject(out);
421: }
422:
423: /**
424: * Reads the data necessary for put() to work in the superclass.
425: */
426: protected void doReadObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
427: maxSize = in.readInt();
428: super.doReadObject(in);
429: }
430:
431: }
部分操作需要追溯其父类代码,这里就不贴了,有兴趣的朋友可以直接到源码阅读
LRUMap对于构建缓存或者连接池之类的技术经常用到,common-collections框架给了现成的实现,大家在不需要修改的情况下,完全可以不必reinvent the wheel,直接用,好用且稳定。


摘自 Change Dir