转载请注明出处哈:http://carlosfu.iteye.com/blog/2238662


0. 相关知识:
查询缓存:绝大数系统主要是读多写少。
缓存作用:减轻数据库压力,提供访问速度。

1. 一级缓存测试用例

(1) 默认开启,不需要有什么配置

(2) 示意图

(3) 测试代码

  1. package com.sohu.tv.cache;
  2. import org.apache.ibatis.session.SqlSession;
  3. import org.junit.After;
  4. import org.junit.Before;
  5. import org.junit.Test;
  6. import com.sohu.tv.bean.Player;
  7. import com.sohu.tv.mapper.PlayerDao;
  8. import com.sohu.tv.test.mapper.BaseTest;
  9. /**
  10. * 一级缓存测试
  11. *
  12. * @author leifu
  13. * @Date 2015-8-3
  14. * @Time 下午9:51:00
  15. */
  16. public class FirstCacheTest extends BaseTest {
  17. private SqlSession sqlSession;
  18. private SqlSession sqlSessionAnother;
  19. @Before
  20. public void before() {
  21. sqlSession = sessionFactory.openSession(false);
  22. sqlSessionAnother = sessionFactory.openSession(false);
  23. }
  24. @After
  25. public void after() {
  26. sqlSession.close();
  27. sqlSessionAnother.close();
  28. }
  29. @Test
  30. public void test1() throws Exception {
  31. PlayerDao playerDao = sqlSession.getMapper(PlayerDao.class);
  32. Player player = playerDao.getPlayerById(1);
  33. System.out.println(player);
  34. playerDao = sqlSession.getMapper(PlayerDao.class);
  35. player = playerDao.getPlayerById(1);
  36. System.out.println(player);
  37. playerDao = sqlSessionAnother.getMapper(PlayerDao.class);
  38. player = playerDao.getPlayerById(1);
  39. System.out.println(player);
  40. }
  41. @Test
  42. public void test2() throws Exception {
  43. PlayerDao playerDao = sqlSession.getMapper(PlayerDao.class);
  44. Player player = playerDao.getPlayerById(1);
  45. System.out.println(player);
  46. //1. session清除或者提交
  47. //        sqlSession1.commit();
  48. //        sqlSession.clearCache();
  49. //2. 增删改查
  50. //        playerDao.savePlayer(new Player(-1, "abcd", 13));
  51. //        playerDao.updatePlayer(new Player(4, "abcd", 13));
  52. playerDao.deletePlayer(4);
  53. player = playerDao.getPlayerById(1);
  54. System.out.println(player);
  55. }
  56. }

2、二级缓存(自带 PerpetualCache)

(0) 示意图

(1) 二级缓存需要开启

总配置文件中,二级缓存也是开启的,不需要设置

  1. <setting name="cacheEnabled" value="true"/>

mapper级别的cache需要开启,在对应的mapper.xml写入

  1. <!--开启本mapper的二级缓存-->
  2. <cache/>

(2) 实体类在二级缓存中需要进行序列化,所以所有实体类需要实现Serializable

(3) 示例:

  1. package com.sohu.tv.cache;
  2. import org.apache.ibatis.session.SqlSession;
  3. import org.junit.After;
  4. import org.junit.Before;
  5. import org.junit.Test;
  6. import com.sohu.tv.bean.Player;
  7. import com.sohu.tv.mapper.PlayerDao;
  8. import com.sohu.tv.test.mapper.BaseTest;
  9. /**
  10. * 二级缓存测试
  11. *
  12. * @author leifu
  13. * @Date 2015-8-3
  14. * @Time 下午10:10:34
  15. */
  16. public class SecondCacheTest extends BaseTest {
  17. private SqlSession sqlSession1 = sessionFactory.openSession();
  18. private SqlSession sqlSession2 = sessionFactory.openSession();
  19. private SqlSession sqlSession3 = sessionFactory.openSession();
  20. private PlayerDao playerDao1;
  21. private PlayerDao playerDao2;
  22. private PlayerDao playerDao3;
  23. @Before
  24. public void before() {
  25. sqlSession1 = sessionFactory.openSession(false);
  26. sqlSession2 = sessionFactory.openSession(false);
  27. sqlSession3 = sessionFactory.openSession(false);
  28. playerDao1 = sqlSession1.getMapper(PlayerDao.class);
  29. playerDao2 = sqlSession2.getMapper(PlayerDao.class);
  30. playerDao3 = sqlSession3.getMapper(PlayerDao.class);
  31. }
  32. @After
  33. public void after() {
  34. sqlSession1.close();
  35. sqlSession2.close();
  36. sqlSession3.close();
  37. }
  38. @Test
  39. public void test1() throws Exception {
  40. int targetId = 1;
  41. //session1 查询并提交
  42. Player player1 = playerDao1.getPlayerById(targetId);
  43. System.out.println("player1: " + player1);
  44. sqlSession1.commit();
  45. //session2 命中后,更新并提交清空缓存
  46. Player player2 = playerDao2.getPlayerById(targetId);
  47. System.out.println("player2: " + player2);
  48. player2.setAge(15);
  49. playerDao2.update(player2);
  50. sqlSession2.commit();
  51. //session3 不命中
  52. Player player3 = playerDao3.getPlayerById(targetId);
  53. System.out.println("player3: " + player3);
  54. }
  55. @Test
  56. public void test2() throws Exception {
  57. int one = 1;
  58. int two = 2;
  59. //session1 查询并提交
  60. Player player1 = playerDao1.getPlayerById(one);
  61. playerDao1.getPlayerById(two);
  62. System.out.println("player1: " + player1);
  63. sqlSession1.commit();
  64. //session2 命中后,更新并提交清空缓存
  65. Player player2 = playerDao2.getPlayerById(one);
  66. System.out.println("player2: " + player2);
  67. player2.setAge(15);
  68. playerDao2.updatePlayer(player2);
  69. sqlSession2.commit();
  70. //session3 不命中
  71. Player player3 = playerDao3.getPlayerById(two);
  72. System.out.println("player3: " + player3);
  73. }
  74. }

(4) 重要日志:

  1. 22:24:37.191 [main] DEBUG com.sohu.tv.mapper.PlayerDao - Cache Hit Ratio [com.sohu.tv.mapper.PlayerDao]: 0.0
  2. 22:24:37.196 [main] DEBUG o.a.i.t.jdbc.JdbcTransaction - Opening JDBC Connection
  3. 22:24:37.460 [main] DEBUG o.a.i.d.pooled.PooledDataSource - Created connection 1695520324.
  4. 22:24:37.460 [main] DEBUG o.a.i.t.jdbc.JdbcTransaction - Setting autocommit to false on JDBC Connection [com.mysql.jdbc.JDBC4Connection@650f9644]
  5. 22:24:37.463 [main] DEBUG c.s.t.mapper.PlayerDao.getPlayerById - ==> Preparing: select id,name,age from players where id=?
  6. 22:24:37.520 [main] DEBUG c.s.t.mapper.PlayerDao.getPlayerById - ==> Parameters: 1(Integer)
  7. 22:24:37.541 [main] DEBUG c.s.t.mapper.PlayerDao.getPlayerById - <== Total: 1
  8. player1: Player [id=1, name=kaka, age=60]
  9. 22:24:37.549 [main] DEBUG o.a.i.t.jdbc.JdbcTransaction - Resetting autocommit to true on JDBC Connection [com.mysql.jdbc.JDBC4Connection@650f9644]
  10. 22:24:37.549 [main] DEBUG o.a.i.t.jdbc.JdbcTransaction - Closing JDBC Connection [com.mysql.jdbc.JDBC4Connection@650f9644]
  11. 22:24:37.549 [main] DEBUG o.a.i.d.pooled.PooledDataSource - Returned connection 1695520324 to pool.
  12. 22:29:13.203 [main] DEBUG com.sohu.tv.mapper.PlayerDao - Cache Hit Ratio [com.sohu.tv.mapper.PlayerDao]: 0.5
  13. player3: Player [id=1, name=kaka, age=60]
  14. 22:29:13.204 [main] DEBUG o.a.i.t.jdbc.JdbcTransaction - Opening JDBC Connection
  15. 22:29:13.204 [main] DEBUG o.a.i.d.pooled.PooledDataSource - Checked out connection 1695520324 from pool.
  16. 22:29:13.204 [main] DEBUG o.a.i.t.jdbc.JdbcTransaction - Setting autocommit to false on JDBC Connection [com.mysql.jdbc.JDBC4Connection@650f9644]
  17. 22:29:13.205 [main] DEBUG c.s.tv.mapper.PlayerDao.updatePlayer - ==> Preparing: update players set name=?,age=? where id=?
  18. 22:29:13.207 [main] DEBUG c.s.tv.mapper.PlayerDao.updatePlayer - ==> Parameters: kaka(String), 60(Integer), 1(Integer)
  19. 22:29:13.208 [main] DEBUG c.s.tv.mapper.PlayerDao.updatePlayer - <== Updates: 1
  20. 22:29:13.210 [main] DEBUG o.a.i.t.jdbc.JdbcTransaction - Committing JDBC Connection [com.mysql.jdbc.JDBC4Connection@650f9644]
  21. 22:29:13.210 [main] DEBUG o.a.i.t.jdbc.JdbcTransaction - Resetting autocommit to true on JDBC Connection [com.mysql.jdbc.JDBC4Connection@650f9644]
  22. 22:29:13.211 [main] DEBUG o.a.i.t.jdbc.JdbcTransaction - Closing JDBC Connection [com.mysql.jdbc.JDBC4Connection@650f9644]
  23. 22:29:13.211 [main] DEBUG o.a.i.d.pooled.PooledDataSource - Returned connection 1695520324 to pool.
  24. 22:29:13.211 [main] DEBUG com.sohu.tv.mapper.PlayerDao - Cache Hit Ratio [com.sohu.tv.mapper.PlayerDao]: 0.3333333333333333
  25. 22:29:13.211 [main] DEBUG o.a.i.t.jdbc.JdbcTransaction - Opening JDBC Connection
  26. 22:29:13.212 [main] DEBUG o.a.i.d.pooled.PooledDataSource - Checked out connection 1695520324 from pool.
  27. 22:29:13.212 [main] DEBUG o.a.i.t.jdbc.JdbcTransaction - Setting autocommit to false on JDBC Connection [com.mysql.jdbc.JDBC4Connection@650f9644]
  28. 22:29:13.212 [main] DEBUG c.s.t.mapper.PlayerDao.getPlayerById - ==> Preparing: select id,name,age from players where id=?
  29. 22:29:13.213 [main] DEBUG c.s.t.mapper.PlayerDao.getPlayerById - ==> Parameters: 1(Integer)
  30. 22:29:13.214 [main] DEBUG c.s.t.mapper.PlayerDao.getPlayerById - <== Total: 1
  31. player2: Player [id=1, name=kaka, age=60]
  32. 22:29:13.215 [main] DEBUG o.a.i.t.jdbc.JdbcTransaction - Resetting autocommit to true on JDBC Connection [com.mysql.jdbc.JDBC4Connection@650f9644]
  33. 22:29:13.216 [main] DEBUG o.a.i.t.jdbc.JdbcTransaction - Closing JDBC Connection [com.mysql.jdbc.JDBC4Connection@650f9644]
  34. 22:29:13.216 [main] DEBUG o.a.i.d.pooled.PooledDataSource - Returned connection 1695520324 to pool.

3、二级缓存(Redis版)

(1) redis使用一个简单的单点实例作为数据源:

引入jedis pom依赖:

  1. <jedis.version>2.8.0</jedis.version>
  2. <protostuff.version>1.0.8</protostuff.version>
  3. <dependency>
  4. <groupId>redis.clients</groupId>
  5. <artifactId>jedis</artifactId>
  6. <version>${jedis.version}</version>
  7. </dependency>
  8. <dependency>
  9. <groupId>com.dyuproject.protostuff</groupId>
  10. <artifactId>protostuff-runtime</artifactId>
  11. <version>${protostuff.version}</version>
  12. </dependency>
  13. <dependency>
  14. <groupId>com.dyuproject.protostuff</groupId>
  15. <artifactId>protostuff-core</artifactId>
  16. <version>${protostuff.version}</version>
  17. </dependency>

jedis获取工具(使用jedispool)

  1. package com.sohu.tv.redis;
  2. import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
  3. import org.slf4j.Logger;
  4. import org.slf4j.LoggerFactory;
  5. import redis.clients.jedis.JedisPool;
  6. /**
  7. * jedisPool获取工具
  8. *
  9. * @author leifu
  10. * @Date 2015年8月4日
  11. * @Time 上午9:01:45
  12. */
  13. public class RedisStandAloneUtil {
  14. private final static Logger logger = LoggerFactory.getLogger(RedisStandAloneUtil.class);
  15. /**
  16. * jedis连接池
  17. */
  18. private static JedisPool jedisPool;
  19. /**
  20. * redis-host
  21. */
  22. private final static String REDIS_HOST = "10.10.xx.xx";
  23. /**
  24. * redis-port
  25. */
  26. private final static int REDIS_PORT = 6384;
  27. static {
  28. try {
  29. jedisPool = new JedisPool(new GenericObjectPoolConfig(), REDIS_HOST, REDIS_PORT);
  30. } catch (Exception e) {
  31. logger.error(e.getMessage(), e);
  32. }
  33. }
  34. public static JedisPool getJedisPool() {
  35. return jedisPool;
  36. }
  37. public static void main(String[] args) {
  38. System.out.println(RedisStandAloneUtil.getJedisPool().getResource().info());
  39. }
  40. }

(2) 如果自己实现mybatis的二级缓存,需要实现org.apache.ibatis.cache.Cache接口,已经实现的有如下:

序列化相关工具代码:

  1. package com.sohu.tv.redis.serializable;
  2. import com.dyuproject.protostuff.LinkedBuffer;
  3. import com.dyuproject.protostuff.ProtostuffIOUtil;
  4. import com.dyuproject.protostuff.Schema;
  5. import com.dyuproject.protostuff.runtime.RuntimeSchema;
  6. import java.util.concurrent.ConcurrentHashMap;
  7. public class ProtostuffSerializer {
  8. private static ConcurrentHashMap<Class<?>, Schema<?>> cachedSchema = new ConcurrentHashMap<Class<?>, Schema<?>>();
  9. public <T> byte[] serialize(final T source) {
  10. VO<T> vo = new VO<T>(source);
  11. final LinkedBuffer buffer = LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE);
  12. try {
  13. final Schema<VO> schema = getSchema(VO.class);
  14. return serializeInternal(vo, schema, buffer);
  15. } catch (final Exception e) {
  16. throw new IllegalStateException(e.getMessage(), e);
  17. } finally {
  18. buffer.clear();
  19. }
  20. }
  21. public <T> T deserialize(final byte[] bytes) {
  22. try {
  23. Schema<VO> schema = getSchema(VO.class);
  24. VO vo = deserializeInternal(bytes, schema.newMessage(), schema);
  25. if (vo != null && vo.getValue() != null) {
  26. return (T) vo.getValue();
  27. }
  28. } catch (final Exception e) {
  29. throw new IllegalStateException(e.getMessage(), e);
  30. }
  31. return null;
  32. }
  33. private <T> byte[] serializeInternal(final T source, final Schema<T> schema, final LinkedBuffer buffer) {
  34. return ProtostuffIOUtil.toByteArray(source, schema, buffer);
  35. }
  36. private <T> T deserializeInternal(final byte[] bytes, final T result, final Schema<T> schema) {
  37. ProtostuffIOUtil.mergeFrom(bytes, result, schema);
  38. return result;
  39. }
  40. private static <T> Schema<T> getSchema(Class<T> clazz) {
  41. @SuppressWarnings("unchecked")
  42. Schema<T> schema = (Schema<T>) cachedSchema.get(clazz);
  43. if (schema == null) {
  44. schema = RuntimeSchema.createFrom(clazz);
  45. cachedSchema.put(clazz, schema);
  46. }
  47. return schema;
  48. }
  49. }
  1. package com.sohu.tv.redis.serializable;
  2. import java.io.Serializable;
  3. public class VO<T> implements Serializable {
  4. private T value;
  5. public VO(T value) {
  6. this.value = value;
  7. }
  8. public VO() {
  9. }
  10. public T getValue() {
  11. return value;
  12. }
  13. @Override
  14. public String toString() {
  15. return "VO{" +
  16. "value=" + value +
  17. '}';
  18. }
  19. }

Redis需要自己来实现,代码如下:

  1. package com.sohu.tv.redis;
  2. import java.util.concurrent.locks.ReadWriteLock;
  3. import java.util.concurrent.locks.ReentrantReadWriteLock;
  4. import org.apache.ibatis.cache.Cache;
  5. import org.slf4j.Logger;
  6. import org.slf4j.LoggerFactory;
  7. import redis.clients.jedis.Jedis;
  8. import redis.clients.jedis.serializable.ProtostuffSerializer;
  9. /**
  10. * mybatis redis实现
  11. *
  12. * @author leifu
  13. * @Date 2015年8月4日
  14. * @Time 上午9:12:37
  15. */
  16. public class MybatisRedisCache implements Cache {
  17. private static Logger logger = LoggerFactory.getLogger(MybatisRedisCache.class);
  18. private String id;
  19. private final ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
  20. private final ProtostuffSerializer protostuffSerializer = new ProtostuffSerializer();
  21. public MybatisRedisCache(final String id) {
  22. if (logger.isInfoEnabled()) {
  23. logger.info("============ MybatisRedisCache id {} ============", id);
  24. }
  25. if (id == null) {
  26. throw new IllegalArgumentException("Cache instances require an ID");
  27. }
  28. this.id = id;
  29. }
  30. @Override
  31. public String getId() {
  32. return this.id;
  33. }
  34. @Override
  35. public int getSize() {
  36. Jedis jedis = null;
  37. int size = -1;
  38. try {
  39. jedis = RedisStandAloneUtil.getJedisPool().getResource();
  40. size = Integer.valueOf(jedis.dbSize().toString());
  41. } catch (Exception e) {
  42. logger.error(e.getMessage(), e);
  43. } finally {
  44. if (jedis != null) {
  45. jedis.close();
  46. }
  47. }
  48. return size;
  49. }
  50. @Override
  51. public void putObject(Object key, Object value) {
  52. if (logger.isInfoEnabled()) {
  53. logger.info("============ putObject key: {}, value: {} ============", key, value);
  54. }
  55. Jedis jedis = null;
  56. try {
  57. jedis = RedisStandAloneUtil.getJedisPool().getResource();
  58. byte[] byteKey = protostuffSerializer.serialize(key);
  59. byte[] byteValue = protostuffSerializer.serialize(value);
  60. jedis.set(byteKey, byteValue);
  61. } catch (Exception e) {
  62. logger.error(e.getMessage(), e);
  63. } finally {
  64. if (jedis != null) {
  65. jedis.close();
  66. }
  67. }
  68. }
  69. @Override
  70. public Object getObject(Object key) {
  71. if (logger.isInfoEnabled()) {
  72. logger.info("============ getObject key: {}============", key);
  73. }
  74. Object object = null;
  75. Jedis jedis = null;
  76. try {
  77. jedis = RedisStandAloneUtil.getJedisPool().getResource();
  78. byte[] bytes = jedis.get(protostuffSerializer.serialize(key));
  79. if (bytes != null) {
  80. object = protostuffSerializer.deserialize(bytes);
  81. }
  82. } catch (Exception e) {
  83. logger.error(e.getMessage(), e);
  84. } finally {
  85. if (jedis != null) {
  86. jedis.close();
  87. }
  88. }
  89. return object;
  90. }
  91. @Override
  92. public Object removeObject(Object key) {
  93. if (logger.isInfoEnabled()) {
  94. logger.info("============ removeObject key: {}============", key);
  95. }
  96. String result = "success";
  97. Jedis jedis = null;
  98. try {
  99. jedis = RedisStandAloneUtil.getJedisPool().getResource();
  100. jedis.del(String.valueOf(key));
  101. } catch (Exception e) {
  102. logger.error(e.getMessage(), e);
  103. } finally {
  104. if (jedis != null) {
  105. jedis.close();
  106. }
  107. }
  108. return result;
  109. }
  110. @Override
  111. public void clear() {
  112. if (logger.isInfoEnabled()) {
  113. logger.info("============ start clear cache ============");
  114. }
  115. String result = "fail";
  116. Jedis jedis = null;
  117. try {
  118. jedis = RedisStandAloneUtil.getJedisPool().getResource();
  119. result = jedis.flushAll();
  120. } catch (Exception e) {
  121. logger.error(e.getMessage(), e);
  122. } finally {
  123. if (jedis != null) {
  124. jedis.close();
  125. }
  126. }
  127. if (logger.isInfoEnabled()) {
  128. logger.info("============ end clear cache result is {}============", result);
  129. }
  130. }
  131. @Override
  132. public ReadWriteLock getReadWriteLock() {
  133. return readWriteLock;
  134. }
  135. }

(3) mapper配置中加入自定义redis二级缓存:

  1. <cache type="com.sohu.tv.redis.MybatisRedisCache"/>

(4) 单元测试同第二节

MyBatis系列目录--5. MyBatis一级缓存和二级缓存(redis实现)的更多相关文章

  1. mybatis基础系列(四)——关联查询、延迟加载、一级缓存与二级缓存

    关本文是Mybatis基础系列的第四篇文章,点击下面链接可以查看前面的文章: mybatis基础系列(三)——动态sql mybatis基础系列(二)——基础语法.别名.输入映射.输出映射 mybat ...

  2. MyBatis 系列五 之 延迟加载、一级缓存、二级缓存设置

    MyBatis的延迟加载.一级缓存.二级缓存设置 首先我们必须分清延迟加载的适用对象 延迟加载 MyBatis中的延迟加载,也称为懒加载,是指在进行关联查询时,按照设置延迟加载规则推迟对关联对象的se ...

  3. mybatis 详解(九)------ 一级缓存、二级缓存

    上一章节,我们讲解了通过mybatis的懒加载来提高查询效率,那么除了懒加载,还有什么方法能提高查询效率呢?这就是我们本章讲的缓存. mybatis 为我们提供了一级缓存和二级缓存,可以通过下图来理解 ...

  4. Mybatis第八篇【一级缓存、二级缓存、与ehcache整合】

    Mybatis缓存 缓存的意义 将用户经常查询的数据放在缓存(内存)中,用户去查询数据就不用从磁盘上(关系型数据库数据文件)查询,从缓存中查询,从而提高查询效率,解决了高并发系统的性能问题. myba ...

  5. MyBatis 一级缓存、二级缓存全详解(一)

    目录 MyBatis 一级缓存.二级缓存全详解(一) 什么是缓存 什么是MyBatis中的缓存 MyBatis 中的一级缓存 初探一级缓存 探究一级缓存是如何失效的 一级缓存原理探究 还有其他要补充的 ...

  6. mybatis源码学习:一级缓存和二级缓存分析

    目录 零.一级缓存和二级缓存的流程 一级缓存总结 二级缓存总结 一.缓存接口Cache及其实现类 二.cache标签解析源码 三.CacheKey缓存项的key 四.二级缓存TransactionCa ...

  7. Mybatis 一级缓存和二级缓存的使用

    目录 Mybatis缓存 一级缓存 二级缓存 缓存原理 Mybatis缓存 官方文档:https://mybatis.org/mybatis-3/zh/sqlmap-xml.html#cache My ...

  8. Mybatis 一级缓存和二级缓存原理区别 (图文详解)

    Java面试经常问到Mybatis一级缓存和二级缓存,今天就给大家重点详解Mybatis一级缓存和二级缓存原理与区别@mikechen Mybatis缓存 缓存就是内存中的数据,常常来自对数据库查询结 ...

  9. [原创]关于mybatis中一级缓存和二级缓存的简单介绍

    关于mybatis中一级缓存和二级缓存的简单介绍 mybatis的一级缓存: MyBatis会在表示会话的SqlSession对象中建立一个简单的缓存,将每次查询到的结果结果缓存起来,当下次查询的时候 ...

随机推荐

  1. Ubuntu14.04安装Matlab2013a

    source url: http://blog.sina.com.cn/s/blog_ec5021d60102v3ky.html 1. 为方便操作,把Matlab镜像文件(iso)重命名为'Matla ...

  2. Linux下进程通信之管道

    每个进程各自有不同的用户地址空间,任何一个进程的全局变量在另一个进程中都看不到,所以进程之间要交换数据必须通过内核,在内核中开辟一块缓冲区,进程1把数据从用户空间拷到内核缓冲区,进程2再从内核缓冲区把 ...

  3. PS 图像调整算法——自动对比度 (Auto Contrast)

    PS 给出的定义: Enhance Monochromatic Contrast: Clips all channels identically. This preserves the overall ...

  4. Hbase 备份的方式

    HBase 备份的方式有三种: 1.下线备份 (1)停止集群. (2)Distcp (3)restore 2.在线备份 -replication 3.在线北大 -CopyTable 4.在线备份-Ex ...

  5. 瑞芯微RK3188如何配置USB摄像头支持

  6. android自定义view实现公章效果

    上次去一个公司面试,面试官问了一个题,怎么用android的自定义view实现一个公章的效果,据说这是华为之前的面试题,我想了下,要是公章的效果,最外层是一个圆,里面是一个五角星,但是这文字怎么画呢, ...

  7. FineReport性能调优的一些办法

    FineReport性能调优的基本思路,就要对应用服务器的内存大小进行合理的设置. 一般服务器默认的内存配置都比较小,在较大型的应用项目中,这点内存是不够的,因此需要加工使其调大. 各应用服务器的内存 ...

  8. 配置SharePoint环境加域提示网络名不可用[已解决]

    今天去客户给机器做备机,带着装好SharePoint07的机器跑过去了,先做个LAN,然后连上机器开始工作:首先当然是改ip地址,然后都改好了开始加域,加了好几次,发现都不行,提示"指定的网 ...

  9. spring boot之入门Controller常用注解

    Controller常用注解 @Controller  处理http请求 @RestController Spring4之后新加的注解,原来返回json数据需要@ResponseBody配合@Cont ...

  10. HashMap实现原理及源码分析(JDK1.7)

    转载:https://www.cnblogs.com/chengxiao/p/6059914.html 哈希表(hash table)也叫散列表,是一种非常重要的数据结构,应用场景及其丰富,许多缓存技 ...