- 更新
- public class OscacheTest extends TestCase {
- private GeneralCacheAdministrator ca = new GeneralCacheAdministrator();
- public void testFlush() {
- ca.putInCache("key1", "object1");
- ca.putInCache("key2", "object2");
- assertEquals("object1", get("key1"));
- ca.flushEntry("key1");
- assertNull(get("key1"));
- assertEquals("object2", get("key2"));
- ca.flushAll();
- assertNull(get("key2"));
- }
- private Object get(String key) {
- try {
- return ca.getFromCache(key, CacheEntry.INDEFINITE_EXPIRY);
- } catch (NeedsRefreshException e) {
- ca.cancelUpdate(key);
- return null;
- }
- }
- }
OSCache更新缓存
最新推荐文章于 2021-02-19 07:15:51 发布