stringredistemplate.opsforvalue().set("test", "100",60*10,timeunit.seconds);//向redis裡存入資料和設定快取時間
stringredistemplate.boundvalueops("test").increment(-1);//val做-1操作
stringredistemplate.opsforvalue().get("test")//根據key獲取快取中的val
stringredistemplate.boundvalueops("test").increment(1);//val +1
stringredistemplate.getexpire("test")//根據key獲取過期時間
stringredistemplate.getexpire("test",timeunit.seconds)//根據key獲取過期時間並換算成指定單位
stringredistemplate.delete("test");//根據key刪除快取
stringredistemplate.haskey("546545");//檢查key是否存在,返回boolean值
stringredistemplate.opsforset().add("red_123", "1","2","3");//向指定key中存放set集合
stringredistemplate.expire("red_123",1000 , timeunit.milliseconds);//設定過期時間
stringredistemplate.opsforset().ismember("red_123", "1")//根據key檢視集合中是否存在指定資料
stringredistemplate.opsforset().members("red_123");//根據key獲取set集合
StringRedisTemplate常用操作
stringredistemplate.opsforvalue set test 100 60 10,timeunit.seconds 向redis裡存入資料和設定快取時間 stringredistemplate.boundvalueops test increment 1 val做 1操作 str...
StringRedisTemplate常用方法
stringredistemplate.opsforvalue set test 100 60 10,timeunit.seconds 向redis裡存入資料和設定快取時間 stringredistemplate.boundvalueops test increment 1 val做 1操作 str...
StringRedisTemplate的使用的方法
根據key刪除快取 stringredistemplate.delete baike 檢查key是否存在,返回boolean值 stringredistemplate.haskey baike 根據key獲取set集合 stringredistemplate.opsforset members ba...