package org.openslx.dozmod.thrift.cache; import java.util.List; import org.apache.thrift.TException; import org.openslx.bwlp.thrift.iface.LectureSummary; import org.openslx.bwlp.thrift.iface.TAuthorizationException; import org.openslx.bwlp.thrift.iface.TInvocationException; import org.openslx.dozmod.thrift.Session; import org.openslx.thrifthelper.ThriftManager; import org.openslx.util.GenericDataCache; import org.openslx.util.GenericDataCache.CacheMode; public class LectureCache { private static final int CACHE_TIME_LIST_MS = 30 * 1000; private static final GenericDataCache> listCache = new GenericDataCache>(CACHE_TIME_LIST_MS) { @Override protected List update() throws TAuthorizationException, TInvocationException, TException { List result = null; int pageSize = Session.getSatelliteConfig().pageSize; for (int i = 0;; ++i) { List page = ThriftManager.getSatClient().getLectureList(Session.getSatelliteToken(), i); if (result == null) { result = page; } else { result.addAll(page); } if (page.size() < pageSize) break; } return result; } }; public static List get(boolean forceRefresh) { return listCache.get(forceRefresh ? CacheMode.NEVER_CACHED : CacheMode.DEFAULT); } }