Пример #1
0
 /**
  * Find Record by cache.
  *
  * @see #find(String, Object...)
  * @param cacheName the cache name
  * @param key the key used to get date from cache
  * @return the list of Record
  */
 public List<Record> findByCache(String cacheName, Object key, String sql, Object... paras) {
   ICache cache = config.getCache();
   List<Record> result = cache.get(cacheName, key);
   if (result == null) {
     result = find(sql, paras);
     cache.put(cacheName, key, result);
   }
   return result;
 }
Пример #2
0
 /**
  * Find first record by cache. I recommend add "limit 1" in your sql.
  *
  * @see #findFirst(String, Object...)
  * @param cacheName the cache name
  * @param key the key used to get date from cache
  * @param sql an SQL statement that may contain one or more '?' IN parameter placeholders
  * @param paras the parameters of sql
  * @return the Record object
  */
 public Record findFirstByCache(String cacheName, Object key, String sql, Object... paras) {
   ICache cache = config.getCache();
   Record result = cache.get(cacheName, key);
   if (result == null) {
     result = findFirst(sql, paras);
     cache.put(cacheName, key, result);
   }
   return result;
 }
Пример #3
0
 /**
  * Paginate by cache.
  *
  * @see #paginate(int, int, String, String, Object...)
  * @return Page
  */
 public Page<Record> paginateByCache(
     String cacheName,
     Object key,
     int pageNumber,
     int pageSize,
     String select,
     String sqlExceptSelect,
     Object... paras) {
   ICache cache = config.getCache();
   Page<Record> result = cache.get(cacheName, key);
   if (result == null) {
     result = paginate(pageNumber, pageSize, select, sqlExceptSelect, paras);
     cache.put(cacheName, key, result);
   }
   return result;
 }