1 50 51 package org.openlaszlo.iv.flash.cache; 52 53 import org.openlaszlo.iv.flash.api.*; 54 import org.openlaszlo.iv.flash.util.*; 55 import java.util.*; 56 57 public class RequestCache extends GenericCache { 58 59 private static RequestCache instance = new RequestCache(); 60 61 private RequestCache() { 62 } 63 64 public static RequestCache getInstance() { 65 return instance; 66 } 67 68 public static CacheSettings getSettings() { 69 return instance.getMySettings(); 70 } 71 72 77 public static FlashOutput getRequest( String key ) { 78 CacheItem item = instance.getItem( key ); 79 if( item == null ) return null; 80 return (FlashOutput) item.getObject(); 81 } 82 83 90 public static void addRequest( String key, FlashOutput fob, long lifespan ) { 91 long now = System.currentTimeMillis(); 92 if( lifespan < 0 ) { 93 lifespan = getSettings().getDefaultExpire(); 94 } 95 if( lifespan == 0 ) { 96 lifespan = Long.MAX_VALUE-now; 97 } 98 long expire = now + lifespan; 99 CacheItem item = new CacheItem( key, fob, fob.getSize(), now, expire ); 100 instance.addItem( item ); 101 } 102 103 } 104 | Popular Tags |