public EncoderCache(int cacheSize) { cache = new CacheLRU(cacheSize); }
/** * Get the specified value URL encoded using the specified encoding * * @param k the value to encode * @param contentEncoding the encoding to use when URL encoding * @return the value URL encoded using the specified encoding * @throws UnsupportedEncodingException if the specified encoding is not supported */ public String getEncoded(String k, String contentEncoding) throws UnsupportedEncodingException { String cacheKey = k + contentEncoding; // Check if we have it in the cache Object encodedValue = cache.getElement(cacheKey); if (encodedValue != null) { return (String) encodedValue; } // Perform the encoding encodedValue = URLEncoder.encode(k, contentEncoding); // Add to cache cache.addElement(cacheKey, encodedValue); return (String) encodedValue; } }
public MetaData cacheMetaData(String stmt, ResultSet rs) throws SQLException { MetaData md; if ((md=(MetaData)mdCache.getElement(stmt))==null) { md= new MetaData(rs.getMetaData()); mdCache.addElement(stmt,md); } return md; }
public DBConnection(Connection conn) { try { oc= conn; if (mdCache==null) mdCache= new CacheLRU(mdCacheSize); debug= logger.isInfoEnabled(); } catch (Exception e) { logger.error("",e); } }
public void reset() { logger.info("Called reset(): invalidating caches..."); configCache= new ConfigCache(cacheSize); fastCache= new CacheLRU(fastCacheSize); }
public void run() { try { e.notifyChange(); if (e.getCacheMode()==EntityConfig.CACHE_MODE_NOCACHE) configCache.remove(e.getName()); fastCache= new CacheLRU(fastCacheSize); // FIXME: locking ??? fastCache used only on getInstanceByURL... } catch (ConfigNotFoundException cnfe) { haveToStop= true; logger.error(this,cnfe); } catch (Exception e) { logger.error(this,e); } } }
configCache= new ConfigCache(cacheSize); fastCache= new CacheLRU(fastCacheSize);