com.j256.ormlite.dao.Dao.clearObjectCache()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(1.9k)|赞(0)|评价(0)|浏览(147)

本文整理了Java中com.j256.ormlite.dao.Dao.clearObjectCache()方法的一些代码示例,展示了Dao.clearObjectCache()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dao.clearObjectCache()方法的具体详情如下:
包路径:com.j256.ormlite.dao.Dao
类名称:Dao
方法名:clearObjectCache

Dao.clearObjectCache介绍

[英]Flush the object cache if it has been enabled. This will remove an objects that are in the cache to reclaim memory. Any future queries will re-request them from the database.
[中]如果对象缓存已启用,则刷新它。这将删除缓存中的对象以回收内存。将来的任何查询都将从数据库中重新请求它们。

代码示例

代码示例来源:origin: j256/ormlite-core

  1. /**
  2. * @see Dao#clearObjectCache()
  3. */
  4. @Override
  5. public void clearObjectCache() {
  6. dao.clearObjectCache();
  7. }

代码示例来源:origin: com.j256.ormlite/ormlite-core

  1. /**
  2. * @see Dao#clearObjectCache()
  3. */
  4. @Override
  5. public void clearObjectCache() {
  6. dao.clearObjectCache();
  7. }

代码示例来源:origin: j256/ormlite-core

  1. @Test
  2. public void testQueryAll() throws Exception {
  3. Dao<Foo, Integer> dao = createDao(Foo.class, true);
  4. dao.setObjectCache(true);
  5. Foo foo = new Foo();
  6. int val = 12312321;
  7. foo.val = val;
  8. assertEquals(1, dao.create(foo));
  9. dao.clearObjectCache();
  10. List<Foo> results = dao.queryForAll();
  11. assertEquals(1, results.size());
  12. assertEquals(foo.id, results.get(0).id);
  13. assertNotSame(foo, results.get(0));
  14. Foo foo2 = dao.queryForId(foo.id);
  15. assertNotNull(foo2);
  16. assertEquals(foo.id, results.get(0).id);
  17. assertSame(results.get(0), foo2);
  18. }

代码示例来源:origin: j256/ormlite-core

  1. @Test
  2. public void testClear() throws Exception {
  3. Dao<Foo, Integer> dao = createDao(Foo.class, true);
  4. LruObjectCache cache = new LruObjectCache(2);
  5. dao.setObjectCache(cache);
  6. Foo foo = new Foo();
  7. int val = 12312321;
  8. foo.val = val;
  9. assertEquals(1, dao.create(foo));
  10. assertEquals(1, cache.size(Foo.class));
  11. Foo result = dao.queryForId(foo.id);
  12. assertSame(foo, result);
  13. dao.clearObjectCache();
  14. result = dao.queryForId(foo.id);
  15. assertNotSame(foo, result);
  16. }

代码示例来源:origin: j256/ormlite-core

  1. assertSame(order1, order2);
  2. accountDao.clearObjectCache();
  3. orderDao.clearObjectCache();
  4. BaseDaoImpl.clearAllInternalObjectCaches();

相关文章