首页天道酬勤utils工具,libcutils

utils工具,libcutils

张世龙 05-05 19:25 117次浏览
@ componentpublicclassredisutils { @ autowiredpublicredistemplateredistemplate; /** *缓存的基本对象、Integer、字符串、实体类等* * @param key缓存的键值* @param value缓存的值*/publictvoidsetcache 缓存基本对象,* * @param key缓存的键值* @param value缓存的值* @param timeout时间* @ param time out time * @ param time publictvoidsetcacheobject (final string key,final T value,final Long timeout,final TimeUnit timeUnit ) redis template.ops for } false=设置失败*/publicbooleanexpire (final string key,final long timeout ) { return expire } key,timeout, TimeUnit.SECONDS } /** *设置有效时间* * @param key Redis键* @param timeout超时时间* @param unit时间单位* @return true=设置成功; false=设定失败。 */publicbooleanexpire (final string key,final long timeout,final TimeUnit unit ) (returnredistemplate.expire ) )。 }/***key中* * @param key键* @确定* @return true中是否存在false */publicbooleanhaskey (string key ) returnredistemplate.hhhore * * @param key缓存密钥* @return缓存密钥对应的数据*/publictgetcacheobject (final string key ) { ValueOperationsString,t operatation } /** *删除单个对象* * @ param key */publicbooleandeleteobject (final string key ) ) returnredistemplate.delete ) key } /** *集合对象* * @param collection多个对象* @ return */publiclongdeleteobject (finalcollection collection ) retured 缓存的List数据* * @param key缓存的键值* @param dataList缓存的List数据* @return缓存的对象*/publictlongsetcachelist () finallisttdatalist (长计数=redis template.opsforlist ) ).rightpushall ) key,datalist ); 返回计数==null? 0 :计数; } /** *缓存的list对象* * @param key缓存的键值* @return缓存键值对应的数据*/publictlisttgetcachelist (final string key 缓存Set * * @param key缓存密钥* @param dataSet缓存的数据* @return缓存数据的对象*/publictboundsetoperationsstring, tsetcacheset(finalset () () ) ) ) ) finalsettdataset (boundsetoperationsstring,tset operation=redis template.) IteratorT it=dataSet.iterator (; while(it.hasnext () set operation.add (it.next ) ); }返回集操作; } /** *获取缓存的set * * @ param key * @ return */publictsettgetcacheset (final string key ) { return redis template.opsforsfors } /** *缓存映射* * @ param key * @ paramdatamap */publictvoidsetcachemap (final string key,final MapString,T dataMap ) IMAP } } /** *缓存的map * * @ param key * @ return */publictmapstring, 在tgetcachemap(finalstringkey ) returnredistemplate.op plate }/* * * hash中输入数据* * @param key Redis键* @param hKey Hash键@ publictvoidsetcachemapvalue (final string key,final tvalue (redis template.opsforhash ).put ) key,hKey,value ); }/* * *散列中的数据* * @param key Redis键* @param hKey Hash键* @return Hash中的对象*/publictgetcachemapvalue (final string finalstringhkey (hashoperationsstring,string,topsforhash=redis template.opsforhash ); returnopsforhash.get(key,hKey ); } /** *从多个Hash检索数据* * @param key Redis键* @param hKeys Hash键集合* @return Hash对象集合*/publictlisttgetmulticachemapvalue (final stash finalcollectionobjecthkeys (returnredistemplate.opsforhash ).multiget(key } /** *缓存的基本对象列表* * @param pattern字符串前缀* @return对象列表*/publiccollection stringkeys (finalstringpattern
disruptor框架使用场景,连接远程redis