- 浏览: 67833 次
文章分类
最新评论
-
小色帝:
我是天才是打发
Jquery实现的Tabs页 -
小色帝:
小色帝 写道1111而温热
Jquery实现的Tabs页 -
小色帝:
1111而温热
Jquery实现的Tabs页
package com.paic.icorepnbs.web.util;
import com.paic.icorepnbs.common.util.LogUtils;
import com.paic.icorepnbs.common.util.SerializableUtil;
import com.paic.icorepnbs.common.util.StringUtils;
import java.util.Map;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.exceptions.JedisException;
public class RedisCacheServiceUtil
{
protected JedisPool jedisPool;
public static final String KEY_NAME_SEP = ":";
protected Jedis getJedis()
throws JedisException
{
Jedis jedis = null;
try {
jedis = this.jedisPool.getResource();
} catch (JedisException e) {
LogUtils.error("获取jedis连接异常", e, null, new Object[0]);
if (jedis != null)
this.jedisPool.returnBrokenResource(jedis);
throw e;
}
return jedis;
}
public void setObject(String key, Object object, int cacheSeconds)
{
Jedis jedis = null;
boolean isBroken = false;
try {
jedis = getJedis();
String storedKey = getRedisStoreKey(object.getClass(), key);
jedis.set(storedKey.getBytes("UTF-8"), SerializableUtil.serializable(object));
if (cacheSeconds >= 0)
jedis.expire(storedKey, cacheSeconds);
}
catch (Exception e) {
isBroken = true;
} finally {
release(jedis, isBroken);
}
}
protected String getRedisStoreKey(Class<?> clazz, String key)
{
StringBuffer keyBuffer = new StringBuffer(clazz.getName()).append(":").append(key);
return keyBuffer.toString();
}
public String getStringValue(String key)
{
String value = null;
Jedis jedis = null;
try {
jedis = getJedis();
if (jedis.exists(key).booleanValue()) {
value = jedis.get(key);
value = ((StringUtils.isNotBlank(value)) && (!("nil".equalsIgnoreCase(value)))) ? value : null;
}
}
catch (Exception e) {
LogUtils.error("InternetRquestAstrictFilter--->get异常", e, null, new Object[0]);
}
finally {
}
return value;
}
public Object getObject(String key, Class<?> clazz)
{
Jedis jedis = null;
boolean isBroken = false;
Object obj = null;
try {
jedis = getJedis();
String storedKey = getRedisStoreKey(clazz, key);
byte[] bytes = jedis.get(storedKey.getBytes("UTF-8"));
obj = SerializableUtil.deSerializable(bytes);
} catch (Exception e) {
isBroken = true;
} finally {
release(jedis, isBroken);
}
return obj;
}
public void setHashField(String redisKey, String itemKey, String value)
{
boolean isBroken = false;
Jedis jedis = null;
try {
jedis = getJedis();
jedis.hset(redisKey, itemKey, value);
} catch (JedisException e) {
isBroken = true;
LogUtils.error("redis执行失败", e, null, new Object[0]);
} finally {
release(jedis, isBroken);
}
}
public void setHashMap(String key, Map<String, String> map, int cacheSeconds)
{
boolean isBroken = false;
Jedis jedis = null;
if ((map != null) && (map.size() > 0))
try {
jedis = getJedis();
jedis.hmset(key, map);
if (cacheSeconds >= 0)
jedis.expire(key, cacheSeconds);
}
catch (JedisException e) {
isBroken = true;
LogUtils.error("redis执行失败,setHashMap(" + key + "," + map.toString() + "," + cacheSeconds + ")", e, null, new Object[0]);
}
finally
{
release(jedis, isBroken);
}
}
public Map<String, String> getHashMapByKey(String key)
{
boolean isBroken = false;
Jedis jedis = null;
Map valueMap = null;
try {
jedis = getJedis();
valueMap = jedis.hgetAll(key);
} catch (JedisException e) {
isBroken = true;
LogUtils.error("redis执行失败,getHashMapByKey(" + key + ")", e, null, new Object[0]);
} finally {
release(jedis, isBroken);
}
return valueMap;
}
public String getItemFromMap(String redisKey, String itemKey)
{
boolean isBroken = false;
Jedis jedis = null;
String result = "";
try {
jedis = getJedis();
result = jedis.hget(redisKey, itemKey);
} catch (JedisException e) {
isBroken = true;
LogUtils.error("redis执行失败,getItemFromMap", e, null, new Object[0]);
} finally {
release(jedis, isBroken);
}
return result;
}
public long removeItemFromHashMap(String redisKey, String itemKey)
{
boolean isBroken = false;
Jedis jedis = null;
try {
jedis = getJedis();
long l = jedis.hdel(redisKey, new String[] { itemKey }).longValue();
return l;
}
catch (JedisException e)
{
isBroken = true;
LogUtils.error("redis执行失败,removeItemFormHashMap(" + redisKey + "," + itemKey + ")", e, null, new Object[0]);
}
finally {
release(jedis, isBroken);
}
return 0L;
}
public void setString(String key, String value, int cacheSeconds)
{
Jedis jedis = null;
boolean isBroken = false;
try {
jedis = getJedis();
jedis.set(key, value);
if (cacheSeconds >= 0)
jedis.expire(key, cacheSeconds);
}
catch (JedisException e) {
isBroken = true;
LogUtils.error("redis执行失败;" + key + ":" + value, e, null, new Object[0]);
} finally {
release(jedis, isBroken);
}
}
public long deleteJedisByKey(String key)
{
boolean isBroken = false;
Jedis jedis = null;
try {
jedis = getJedis();
long l = jedis.del(key).longValue();
return l;
}
catch (Exception e)
{
isBroken = true;
LogUtils.error("redis执行,移除key:" + key + ",失败。", e, null, new Object[0]);
} finally {
release(jedis, isBroken);
}
return 0L;
}
public boolean existKey(String key)
{
Jedis jedis = null;
boolean isBroken = false;
try {
jedis = getJedis();
boolean bool1 = jedis.exists(key).booleanValue();
return bool1;
}
catch (Exception e)
{
isBroken = true;
LogUtils.error("existKey异常!", e, null, new Object[0]);
} finally {
release(jedis, isBroken);
}
return false;
}
public Long expire(String key, int seconds)
{
Long result = null;
boolean isBroken = false;
Jedis jedis = null;
try {
jedis = getJedis();
result = jedis.expire(key, seconds);
} catch (Exception e) {
isBroken = true;
LogUtils.error("expire异常:", e, null, new Object[0]);
} finally {
release(jedis, isBroken);
}
return result;
}
public void release(Jedis jedis, boolean isBroken) {
if (jedis != null)
if (isBroken)
this.jedisPool.returnBrokenResource(jedis);
else
this.jedisPool.returnResource(jedis);
}
public void setJedisPool(JedisPool jedisPool)
{
this.jedisPool = jedisPool;
}
}
import com.paic.icorepnbs.common.util.LogUtils;
import com.paic.icorepnbs.common.util.SerializableUtil;
import com.paic.icorepnbs.common.util.StringUtils;
import java.util.Map;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.exceptions.JedisException;
public class RedisCacheServiceUtil
{
protected JedisPool jedisPool;
public static final String KEY_NAME_SEP = ":";
protected Jedis getJedis()
throws JedisException
{
Jedis jedis = null;
try {
jedis = this.jedisPool.getResource();
} catch (JedisException e) {
LogUtils.error("获取jedis连接异常", e, null, new Object[0]);
if (jedis != null)
this.jedisPool.returnBrokenResource(jedis);
throw e;
}
return jedis;
}
public void setObject(String key, Object object, int cacheSeconds)
{
Jedis jedis = null;
boolean isBroken = false;
try {
jedis = getJedis();
String storedKey = getRedisStoreKey(object.getClass(), key);
jedis.set(storedKey.getBytes("UTF-8"), SerializableUtil.serializable(object));
if (cacheSeconds >= 0)
jedis.expire(storedKey, cacheSeconds);
}
catch (Exception e) {
isBroken = true;
} finally {
release(jedis, isBroken);
}
}
protected String getRedisStoreKey(Class<?> clazz, String key)
{
StringBuffer keyBuffer = new StringBuffer(clazz.getName()).append(":").append(key);
return keyBuffer.toString();
}
public String getStringValue(String key)
{
String value = null;
Jedis jedis = null;
try {
jedis = getJedis();
if (jedis.exists(key).booleanValue()) {
value = jedis.get(key);
value = ((StringUtils.isNotBlank(value)) && (!("nil".equalsIgnoreCase(value)))) ? value : null;
}
}
catch (Exception e) {
LogUtils.error("InternetRquestAstrictFilter--->get异常", e, null, new Object[0]);
}
finally {
}
return value;
}
public Object getObject(String key, Class<?> clazz)
{
Jedis jedis = null;
boolean isBroken = false;
Object obj = null;
try {
jedis = getJedis();
String storedKey = getRedisStoreKey(clazz, key);
byte[] bytes = jedis.get(storedKey.getBytes("UTF-8"));
obj = SerializableUtil.deSerializable(bytes);
} catch (Exception e) {
isBroken = true;
} finally {
release(jedis, isBroken);
}
return obj;
}
public void setHashField(String redisKey, String itemKey, String value)
{
boolean isBroken = false;
Jedis jedis = null;
try {
jedis = getJedis();
jedis.hset(redisKey, itemKey, value);
} catch (JedisException e) {
isBroken = true;
LogUtils.error("redis执行失败", e, null, new Object[0]);
} finally {
release(jedis, isBroken);
}
}
public void setHashMap(String key, Map<String, String> map, int cacheSeconds)
{
boolean isBroken = false;
Jedis jedis = null;
if ((map != null) && (map.size() > 0))
try {
jedis = getJedis();
jedis.hmset(key, map);
if (cacheSeconds >= 0)
jedis.expire(key, cacheSeconds);
}
catch (JedisException e) {
isBroken = true;
LogUtils.error("redis执行失败,setHashMap(" + key + "," + map.toString() + "," + cacheSeconds + ")", e, null, new Object[0]);
}
finally
{
release(jedis, isBroken);
}
}
public Map<String, String> getHashMapByKey(String key)
{
boolean isBroken = false;
Jedis jedis = null;
Map valueMap = null;
try {
jedis = getJedis();
valueMap = jedis.hgetAll(key);
} catch (JedisException e) {
isBroken = true;
LogUtils.error("redis执行失败,getHashMapByKey(" + key + ")", e, null, new Object[0]);
} finally {
release(jedis, isBroken);
}
return valueMap;
}
public String getItemFromMap(String redisKey, String itemKey)
{
boolean isBroken = false;
Jedis jedis = null;
String result = "";
try {
jedis = getJedis();
result = jedis.hget(redisKey, itemKey);
} catch (JedisException e) {
isBroken = true;
LogUtils.error("redis执行失败,getItemFromMap", e, null, new Object[0]);
} finally {
release(jedis, isBroken);
}
return result;
}
public long removeItemFromHashMap(String redisKey, String itemKey)
{
boolean isBroken = false;
Jedis jedis = null;
try {
jedis = getJedis();
long l = jedis.hdel(redisKey, new String[] { itemKey }).longValue();
return l;
}
catch (JedisException e)
{
isBroken = true;
LogUtils.error("redis执行失败,removeItemFormHashMap(" + redisKey + "," + itemKey + ")", e, null, new Object[0]);
}
finally {
release(jedis, isBroken);
}
return 0L;
}
public void setString(String key, String value, int cacheSeconds)
{
Jedis jedis = null;
boolean isBroken = false;
try {
jedis = getJedis();
jedis.set(key, value);
if (cacheSeconds >= 0)
jedis.expire(key, cacheSeconds);
}
catch (JedisException e) {
isBroken = true;
LogUtils.error("redis执行失败;" + key + ":" + value, e, null, new Object[0]);
} finally {
release(jedis, isBroken);
}
}
public long deleteJedisByKey(String key)
{
boolean isBroken = false;
Jedis jedis = null;
try {
jedis = getJedis();
long l = jedis.del(key).longValue();
return l;
}
catch (Exception e)
{
isBroken = true;
LogUtils.error("redis执行,移除key:" + key + ",失败。", e, null, new Object[0]);
} finally {
release(jedis, isBroken);
}
return 0L;
}
public boolean existKey(String key)
{
Jedis jedis = null;
boolean isBroken = false;
try {
jedis = getJedis();
boolean bool1 = jedis.exists(key).booleanValue();
return bool1;
}
catch (Exception e)
{
isBroken = true;
LogUtils.error("existKey异常!", e, null, new Object[0]);
} finally {
release(jedis, isBroken);
}
return false;
}
public Long expire(String key, int seconds)
{
Long result = null;
boolean isBroken = false;
Jedis jedis = null;
try {
jedis = getJedis();
result = jedis.expire(key, seconds);
} catch (Exception e) {
isBroken = true;
LogUtils.error("expire异常:", e, null, new Object[0]);
} finally {
release(jedis, isBroken);
}
return result;
}
public void release(Jedis jedis, boolean isBroken) {
if (jedis != null)
if (isBroken)
this.jedisPool.returnBrokenResource(jedis);
else
this.jedisPool.returnResource(jedis);
}
public void setJedisPool(JedisPool jedisPool)
{
this.jedisPool = jedisPool;
}
}
发表评论
-
c3p0代码动态切换数据源
2018-08-06 17:54 1074public class PARPDatasource imp ... -
sql 优化开多个线程跑
2018-07-11 09:54 678select /*+ parallel(8) */ * fr ... -
redis 事物限制频率和获得令牌
2018-07-11 02:50 926package com.dongnaoedu.tony.ser ... -
Redis分布式锁解决抢购问题
2018-07-11 02:39 1327废话不多说,首先分享一个业务场景-抢购。一个典型的高并发问题, ... -
StringWriter 接收异常信息
2018-07-05 18:42 443try { int a=1/0; } catch (E ... -
jedis 操作redis
2018-06-26 09:13 368//连接redis ,redis的默认端口是6379 Je ... -
多线程缓存优化思想
2018-06-06 15:33 3621.背景 题库 随机生成N张试卷,每张试卷M个题目,每个题目要 ... -
网络编程之使用HttpClient批量上传文件
2018-05-28 01:12 541网络编程之使用HttpClient批量上传文件(一) 2014 ... -
oracle 正则表达式 替换 ‘’:
2018-05-18 18:04 578select /*+ parallel(8) */ t.na ... -
java web 导出 下拉 excle
2018-05-15 17:03 457@RequestMapping(value = "/ ... -
Java Socket编程
2016-12-28 23:28 339对于Java Socket编程而言,有两个概念,一个是Serv ... -
Java多线程学习(吐血超详细总结)
2016-12-27 17:15 415目录(?)[-] 1.一扩展javalangThread类 2 ... -
JAVA多线程实现的三种方式
2016-12-27 17:16 417Java多线程实现方式主要有三种:继承Thread类、实现Ru ... -
Maven 入门菜鸟教程
2016-12-02 10:02 1175学习maven的使用,看到一篇很实用的入门教程(菜鸟级入门) ... -
Java 读写Properties配置文件
2016-08-22 15:00 402Java 读写Properties配置文件 1.Pro ... -
JAVA前端与后端参数传递方法小结
2016-07-26 10:54 46561,从Action中传值到JSP页面的方法 ①在Actio ... -
苟富贵
2013-02-25 09:43 0额梵蒂冈过v梵蒂冈北方多汇报地方环保 -
Request的getParameter和getAttribute方法的区别
2013-01-22 10:01 649HttpServletRequest.getParameter ... -
Eclipse快捷键小结
2012-12-26 11:26 735Eclipse快捷键小结 Eclipse ... -
JAVA去空格
2012-12-20 16:53 652String ccc=” he l l o , w o r l ...
相关推荐
基于Springboot的实验报告系统源码数据库文档.zip
GEE训练教程——Landsat5、8和Sentinel-2、DEM和各2哦想指数下载
基于springboot智能健康饮食系统源码数据库文档.zip
基于SpringBoot的校园服务系统源码数据库文档.zip
内容概要: IXIA测试仪的基本配置.doc ixia测试仪基础使用示例.doc IxNetwork如何进行抓包回放-V1.0.pdf IxNetwork如何自定义报文-V2.0.pdf ixia构造ip分片方法.txt IxNetwork使用简介.pdf 适用人群:网络协议造包、打流相关的测试工程技术人员,想要学习的同学可以下载哈 使用场景:构造pcap包,打流 Ixia简介 IXIA使用的是Server-client模式,Server端在测试仪表的主机上,在开机后会随着主机内的操作系统的启动而自动启动,一般情况下不需要人为的手工启动。因此在通常不需要为主机配置专用的显示器和键盘。 client端包括两个测试软件: Ixia Explorer和ScriptMate。这两个软件一般安装在测试用计算机上,在仪表自带的主机中也有这两个软件。根据测试项目的不同来选择使用不同的软件。Ixia Explorer主要提供数据流的测试,针对设备的功能进行测试; ScriptMate提供各种性能测试窗口,针对设备的性能进行测试。 Auto:自动分配;
基于Python+Django花卉商城系统源码数据库文档.zip
Umi-OCR-main.zip
基于微信小程序开发的促销抽奖小工具源码,适用于初学者了解小程序开发过程以及简单抽奖工具的实现。
GEE训练教程——Landsat5、8和Sentinel-2、DEM和各2哦想指数下载
以下是一个关于Spring Boot设计的资源描述及项目源码的简要概述: Spring Boot设计资源描述 Spring Boot是一个为基于Spring的应用提供快速开发工具的框架,其设计旨在简化Spring应用的初始搭建和开发过程。以下是一些关键资源: Spring Boot官方文档:详细阐述了Spring Boot的核心特性、自动配置原理、起步依赖、内嵌式服务器等关键概念。这是学习和掌握Spring Boot设计的首选资源。 在线教程与视频:各大在线教育平台提供了丰富的Spring Boot教程和视频课程,从基础入门到高级应用,帮助开发者全面了解和掌握Spring Boot设计。 书籍与电子资料:许多技术书籍和在线电子资料深入讲解了Spring Boot的设计原理、最佳实践和项目案例,为开发者提供了宝贵的学习资源。 项目源码示例 以下是一个简单的Spring Boot项目源码示例,用于演示Spring Boot的基本结构和自动配置功能: java // 引入Spring Boot依赖 @SpringBootApplication public class MySpri
基于springboot美妆领域管理系统源码数据库文档.zip
tables-3.7.0+gpl-cp37-cp37m-win_amd64.whl
算法是计算机科学的核心,它们在解决各种问题时发挥着关键作用。一个好的算法不仅可以提高程序的效率,还可以简化复杂的问题。下面我将通过一个具体的例子——快速排序算法(Quick Sort)——来展示算法的实现过程,包括资源描述和项目源码。 ### 快速排序算法简介 快速排序是一种高效的排序算法,采用分治法的思想。其基本步骤如下: 1. 从数列中挑出一个元素,称为“基准”(pivot)。 2. 重新排序数列,所有比基准值小的元素放到基准前面,所有比基准值大的元素放到基准后面(相同的数可以到任一边)。在这个分割结束之后,该基准就处于数列的中间位置。这个称为分割(partition)操作。 3. 递归地(recursive)把小于基准值的子数列和大于基准值的子数列排序。 ### 资源描述 快速排序算法因其高效性和简洁性,在实际应用中非常受欢迎。它的时间复杂度平均为 O(n log n),最坏情况下为 O(n^2),但这种情况很少发生。快速排序的空间复杂度为 O(log n),因为它使用了递归来实现。 快速排序的一个典型应用场景是在数据库系统中对大量数据进行排序。由于它的高效性,快速排序
基于springboot农场投入品运营线上管理系统源码数据库文档.zip
基于springboot个性化影院推荐系统源码数据库文档.zip
linux基础进阶笔记,配套视频:https://www.bilibili.com/list/474327672?sid=4493093&spm_id_from=333.999.0.0&desc=1
小程序 微信自动抢红包动态库.zip程序资源学习资料参考
小程序 iOS版微信抢红包插件(支持后台抢红包).zip
经典-FPGA时序约束教程
基于springboot的智慧点餐系统源码数据库文档.zip