Beispiel #1
0
 public PriceListItem getItemPrice(int id, byte dat) throws SQLException, Exception {
   if (tempCache != null
       && tempCache.ID() == id
       && tempCache.Data() == dat
       && (System.currentTimeMillis() - tempCache.getTime()) / 1000 < tempCacheTTL) {
     // use temp
     return tempCache;
   }
   if (databaseType == DBType.MYSQL && !useCache) {
     tempCache = MySQLpricelist.getItem(id, dat);
   } else {
     updateCache(true);
     PriceListItem f = null;
     for (PriceListItem p : priceList) {
       if (p != null && p.ID() == id && p.Data() == dat) {
         f = p;
         break;
       }
     }
     if (f == null) {
       return null;
     }
     if (tempCache == null) {
       tempCache = new PriceListItem(f);
     } else {
       tempCache.Set(f);
     }
   }
   return tempCache;
 }
Beispiel #2
0
 public boolean itemExists(JItem check) throws SQLException, Exception {
   if (check == null) {
     return false;
   }
   updateCache(true);
   if (databaseType == DBType.MYSQL && dbCacheTTL == 0) {
     tempCache = MySQLpricelist.getItem(check);
   } else { // should be in cache
     int i = priceList.indexOf(new PriceListItem(check));
     if (i < 0) {
       return false;
     } // else
     if (tempCache == null) {
       tempCache = new PriceListItem(priceList.get(i));
     } else {
       tempCache.Set(priceList.get(i));
     }
   }
   return tempCache != null;
 }