public ModelCache build() { final ModelCache cache = new ModelCache(); if (isValidOptionsForMemoryCache()) { cache.setMemoryCache(new LruCache<String, CacheItem>(mMemoryCacheMaxSize)); } if (isValidOptionsForDiskCache()) { new AsyncTask<Void, Void, DiskLruCache>() { @Override protected DiskLruCache doInBackground(Void... params) { try { DiskLruCache c = DiskLruCache.open(mDiskCacheLocation, 0, 2, mDiskCacheMaxSize); cache.setDiskCache(c); return c; } catch (IOException e) { e.printStackTrace(); return null; } } @Override protected void onPostExecute(DiskLruCache result) { // cache.setDiskCache(result); } }.execute(); } return cache; }
@Override protected Object doInBackground(Void... voids) { if (modelCache != null) { return modelCache.put(key, obj, expiresAt); } else { return null; } }
@Override protected Object doInBackground(Void... voids) { if (modelCache != null) { return modelCache.get(key, checkExpiration); } else { return null; } }