package org.commcare.models.database.user;

import org.javarosa.core.services.storage.ExpressionCacher;
import org.javarosa.xpath.CachedExpression;
import org.javarosa.xpath.InFormCacheableExpr;

/**
 * Created by amstone326 on 1/10/18.
 */

public class AndroidExpressionCacher extends ExpressionCacher {

    public AndroidExpressionCacher() {
    }

    @Override
    public void cache(CachedExpression value) {

    }

    @Override
    public Object getCachedValue(InFormCacheableExpr key) {
        //return getCacheStorage().read(recordIdOfCachedExpression).getEvalResult();
        return null;
    }

}

@@ -37,16 +37,105 @@
 .user;%0A%0A
+import org.commcare.CommCareApplication;%0Aimport org.commcare.models.database.SqlStorage;%0A
 import o
@@ -464,231 +464,689 @@
 lic 
-void cache(CachedExpression value) %7B%0A%0A    %7D%0A%0A    @Override%0A    public Object getCachedValue(InFormCacheableExpr key) %7B%0A        //return getCacheStorage().read(recordIdOfCachedExpression).getEvalResult();%0A        return null
+int cache(InFormCacheableExpr expression, Object value) %7B%0A        CachedExpression cached = new CachedExpression(expression, value);%0A        getCacheStorage().write(cached);%0A        return cached.getID();%0A    %7D%0A%0A    @Override%0A    public Object getCachedValue(int idOfStoredCache) %7B%0A        CachedExpression cached = getCacheStorage().read(idOfStoredCache);%0A        if (cached == null) %7B%0A            return null;%0A        %7D else %7B%0A            return cached.getEvalResult();%0A        %7D%0A    %7D%0A%0A    private SqlStorage%3CCachedExpression%3E getCacheStorage() %7B%0A        return CommCareApplication.instance()%0A                .getUserStorage(CachedExpression.STORAGE_KEY, CachedExpression.class)
 ;%0A  

implement actual caching