Android Dual Cache

I just released the version 2.0.0 of my Android library for caching. Tired to choose between DiskLruCache and LruCache ? Simply use this android lib and get the best of disk and RAM caching.

Find everything you need about the dual cache on the github page.


  1. There is a practical example of this library?

  2. Hi,
    I’m getting this
    “The context provided to this library is null. Please provide a proper context according the lifecycle of the application (you should provide the application context).” How to provide context?

  3. sandeep kosta

    May 15, 2016 at 2:43 pm

    hey vincent
    i have been trying to use your caching library in my project and it is not working, i gave up after trying a lot .
    here is my code

    private CacheLibrary(Context context){
    mContext = context;
    /* mRamCacheSize = intent.getIntExtra(EXTRA_RAM_CACHE_SIZE,50);
    mDiskCacheSize = intent.getIntExtra(EXTRA_DISK_CACHE_SIZE, 100);
    mCacheId = intent.getStringExtra(EXTRA_ID_CACHE);*/
    mCache = new DualCacheBuilder(“cache_Id1”, 2, String.class).useDefaultSerializerInRam(50).useDefaultSerializerInDisk(100,true);
    // enableDiskBuilder();
    // mCache = mDualCacheDiskBuilder.noDisk(); // bydefault disk caching would be disabled because some module would be eligible for sqlite caching not disk

    public void setCache(String key,Object value)
    if(key!=null || value!=null ){
    mCache.put(key, value.toString());

    public Object getCache(String key)
    String cacheResp =mCache.get(key);
    Object obj =null;
    obj = new JSONTokener(cacheResp).nextValue();
    if(obj instanceof JSONObject)
    obj = new JSONObject(obj.toString());
    obj = new JSONArray(obj.toString());
    }catch (JSONException jsonExp)
    KaHOLog.writeErrorLog(“There is an error while retriving the data from cache”);
    return obj;


    but everytime it is returning empty

Leave a Reply

Your email address will not be published.


fifteen − 13 =

© 2018 Vincent Brison

Theme by Anders NorénUp ↑