public void put ( String key , T object ) { // Synchronize put on each entry. Gives concurrent editions on different entries, and atomic // modification on the same entry. if ( ramMode . equals ( DualCacheRamMode . ENABLE_WITH_REFERENCE ) ) { ramCacheLru . put ( key , object ) ; } String ramSerialized = null ; if ( ramMode . equals ( DualCacheRamMode . ENABLE_WITH_SPECIFIC_SERIALIZER ) ) { ramSerialized = ramSerializer . toString ( object ) ; ramCacheLru . put ( key , ramSerialized ) ; } if ( diskMode . equals ( DualCacheDiskMode . ENABLE_WITH_SPECIFIC_SERIALIZER ) ) { try { dualCacheLock . lockDiskEntryWrite ( key ) ; DiskLruCache . Editor editor = diskLruCache . edit ( key ) ; if ( ramSerializer == diskSerializer ) { // Optimization if using same serializer editor . set ( 0 , ramSerialized ) ; } else { editor . set ( 0 , diskSerializer . toString ( object ) ) ; } editor . commit ( ) ; } catch ( IOException e ) { logger . logError ( e ) ; } finally { dualCacheLock . unLockDiskEntryWrite ( key ) ; } } }
Put an object in cache .