    public <T> void addToCache(String k, Class<?> type, List<T> ret) {
        if (k == null) {
            return;
        }
        if (ret != null && !k.endsWith("idlist")) {
            Hashtable<Class<?>, Hashtable<ObjectId, Object>> idCacheClone = cloneIdCache();
            for (T record : ret) {
                if (idCacheClone.get(type) == null) {
                    idCacheClone.put(type, new Hashtable<ObjectId, Object>());
                }
                idCacheClone.get(type).put(annotationHelper.getId(record), record);
            }
            setIdCache(idCacheClone);
        }
        CacheElement<T> e = new CacheElement<T>(ret);
        e.setLru(System.currentTimeMillis());
        Hashtable<Class<?>, Hashtable<String, CacheElement>> cl = (Hashtable<Class<?>, Hashtable<String, CacheElement>>) cache.clone();
        if (cl.get(type) == null) {
            cl.put(type, new Hashtable<String, CacheElement>());
        }
        cl.get(type).put(k, e);
        cache = cl;
    }

    public <T> void addToCache(String k, Class<?> type, List<T> ret) {
        if (k == null) {
            return;
        }
        if (!k.endsWith("idlist")) {
            Hashtable<Class<?>, Hashtable<ObjectId, Object>> idCacheClone = cloneIdCache();
            for (T record : ret) {
                if (idCacheClone.get(type) == null) {
                    idCacheClone.put(type, new Hashtable<ObjectId, Object>());
                }
                idCacheClone.get(type).put(annotationHelper.getId(record), record);
            }
            setIdCache(idCacheClone);
        }
        CacheElement<T> e = new CacheElement<T>(ret);
        e.setLru(System.currentTimeMillis());
        Hashtable<Class<?>, Hashtable<String, CacheElement>> cl = (Hashtable<Class<?>, Hashtable<String, CacheElement>>) cache.clone();
        if (cl.get(type) == null) {
            cl.put(type, new Hashtable<String, CacheElement>());
        }
        cl.get(type).put(k, e);
        cache = cl;
    }
