在Jpa Dao層接口
使用修改@Modifying注解? ? 需要在service類里面在相應(yīng)的方法上加入@Transactional注解
key值接參數(shù)列表對(duì)象里面的值
**************************************************************************
@CacheEvict(key ="gathering.id",value ="gathering")??
public void update(Gathering gathering)
key值接參數(shù)列表的值
@CacheEvict(key ="#id",value ="gathering")? ?***? ?@Cacheable(key ="#id",value ="gathering")
public Gathering findById(String id)
***************************************************************************
ValueOperations ops =srt.opsForValue();
String aaa = ops.get("aaa" + id);? ?//取出redis中的值
ops.set("aaa"+id,JsonUtils.objectToJson(articleDao.findById(id).get()),10,TimeUnit.MINUTES); //設(shè)置redis緩存 過期時(shí)間為 10分鐘
******************************************************************************
redis依賴報(bào)錯(cuò) 把pom.xml 的版本加上
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>2.1.6.RELEASE</version>? ? //選擇版本
</dependency>
**********************************************************************************
docker start+ name 名 啟動(dòng)
docker stop+name名 或 id 停止運(yùn)行
docker ps? 查詢 正在運(yùn)行的所有鏡像
docker images 查看所有的鏡像?
************************************************************************************
hashmap可以設(shè)置線程同步?
collections.synchronizedmap(Map map)
----------
hashmap 的工作原理,使用put(key ,value) 存值,get(key)取值
當(dāng)使用put 存值的時(shí)候,會(huì)對(duì)key調(diào)用hashcode方法,返回hashcode的buket的位置來保存entry 對(duì)象
----------
hashmap 與hashset的區(qū)別
hashset 是包裝了hashmap ,hashset 存入值的時(shí)候,實(shí)際上此值是以hashmap的key來進(jìn)行保存
hashmap 是初始化了一個(gè)entry 數(shù)組,來實(shí)現(xiàn)key value的保存
hashmap的entry有四個(gè)變量:key value hash next ,next是當(dāng)hash保存值時(shí)沖突,來指向下一個(gè)值
hashmap 遍歷方式 keyset? map.entry
hashmap保存的順序
第一步 對(duì)key調(diào)用hashcode 進(jìn)行hash計(jì)算,獲取應(yīng)保存在數(shù)組中的index
第二步 查詢數(shù)組中的index指向的元素是否是空,是空就添加
第三部 如果不是空,就從entry 的 next指定的元素 ,判斷key是否相等,相等則替換
第四部 如果沒有相等的,就將鏈表頭的值給entry 的next變量,將元素插入entry數(shù)組