示例#1
0
 /** {@inheritDoc} */
 public void put(Object key, Object obj) {
   if (key == null || obj == null) throw new IllegalArgumentException();
   final CacheObjectBroker broker = m_cache.getCacheObjectBroker();
   final int objSize = broker.getEncodedSizeOf(obj);
   while (true) {
     final ByteBuffer buf;
     try {
       buf = m_bufAlloc.allocByteBuffer(objSize);
     } catch (OutOfMemoryError e) {
       if (spillOneObject()) continue;
       throw e;
     }
     broker.encodeToByteBuffer(buf, obj);
     synchronized (this) {
       m_lruMap.put(key, buf);
       m_curSize += objSize;
     }
     break;
   }
 }