/** * 添加Jokes缓存 * * @param result * @param page */ @Override public void addResultCache(String result, int page) { PictureCache pictureCache = new PictureCache(); pictureCache.setResult(result); pictureCache.setPage(page); pictureCache.setTime(System.currentTimeMillis()); mPictureCacheDao.insert(pictureCache); }
/** * 根据页码获取缓存数据 * * @param page * @return */ @Override public ArrayList<Picture> getCacheByPage(int page) { QueryBuilder<PictureCache> query = mPictureCacheDao.queryBuilder().where(PictureCacheDao.Properties.Page.eq("" + page)); if (query.list().size() > 0) { return (ArrayList<Picture>) JSONParser.toObject( query.list().get(0).getResult(), new TypeToken<ArrayList<Picture>>() {}.getType()); } else { return new ArrayList<Picture>(); } }
/** 清楚全部缓存 */ public void clearAllCache() { mPictureCacheDao.deleteAll(); }