mybatis缓存解析

mybatis的缓存 首先来看下mybatis对缓存的规范,规范嘛就是定义的接口啦。 缓存接口 ​ Cache接口 定义了缓存的方法 public interface Cache { /**获取缓存的id * @return The identifier of this cache */ String getId(); /**添加缓存 * @param key Can be any object but usually it is a {@link CacheKey} * @param value The result of a select. */ void putObject(Object key, Object value); /**根据缓存键获取缓存 * @param key The key * @return The object stored in the cache. */ Object getObject(Object key); /**移除缓存 * As of 3.3.0 this method is only called during a rollback * for any previous value that was missing in the cache. * This lets any blocking cache to release the lock that * may have previously put on the key. * A blocking cache puts a lock when a value is null * and releases it when the value is back again. * This way other threads will wait for the value to be * available instead of hitting the database. * * * @param key The key * @return Not used */ Object removeObject(Object key); /** * Clears this cache instance */ void clear(); /** * Optional. This method is not called by the core. * * @return The number of elements stored in the cache (not its capacity). */ int getSize(); /** * Optional. As of 3.2.6 this method is no longer called by the core. * * Any locking needed by the cache must be provided internally by the cache provider. * * @return A ReadWriteLock */ ReadWriteLock getReadWriteLock(); } 实现 ...

November 17, 2021 · 12 min

mybatis的mapper执行过程

November 10, 2021 · 0 min

mybatis核心组件

sequenceDiagram participant SqlSession participant Excutor participant StatementHandler participant parameterHandler participant ResultSetHandler participant TypeHandler participant ResultSet participant JDBC SqlSession->>Excutor: Excutor->>StatementHandler: StatementHandler-->>parameterHandler: StatementHandler-->>JDBC: parameterHandler-->>TypeHandler: parameterHandler->>JDBC: JDBC->>ResultSet: ResultSet-->>TypeHandler: ResultSet-->>ResultSetHandler: TypeHandler-->>ResultSetHandler: ResultSetHandler->>StatementHandler: StatementHandler->>Excutor: Excutor->>SqlSession: Note left of SqlSession: asa flowchart TD subgraph configuration mappedStatement1 --> mappedStatement2 end configuration: ...

November 10, 2021 · 2 min

7全文索引

MySQL 5.7 中文全文检索 在 MySQL 5.7.6 之前,全文索引只支持英文全文索引,不支持中文全文索引,需要利用分词器把中文段落预处理拆分成单词,然后存入数据库。 从 MySQL 5.7.6 开始,MySQL内置了ngram全文解析器,用来支持中文、日文、韩文分词。 本文使用的MySQL 版本是 5.7.24,InnoDB数据库引擎。 ...

October 8, 2021 · 7 min

mysql基本语句

唯一键 mysql 5.6 及以下 alter ignore table xy_member_game_count add UNIQUE unique_name (uid,time); mysql 5.7 以上 1.删除表中重复数据,只保留重复中的一条 delete from member where (uid,time) in (select uid,time from ( select uid,time from member group by uid,time having count()>1) a) and id not in ( select min(id) from (select min(id) as id from member group by uid,time having count()>1 ) b) 2. 新增唯一键 alter table member add UNIQUE unique_name (uid,time); sql:mysql:on和where区别,on后可跟多个条件 数据库在通过连接两张或多张表来返回记录时,都会生成一张中间的临时表,然后再将这张临时表返回给用户。 ...

October 8, 2021 · 1 min
总访问量 总访客数