Commit 5affa9c3 by manxiaoqiang

test pom

parent b220960f
......@@ -2,6 +2,7 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="e2e217e2-2dd6-4c6f-ad19-b1cba46bc7ad" name="Default" comment="">
<change type="DELETED" beforePath="$PROJECT_DIR$/src/main/java/util/RedisUtilNew.java" afterPath="" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/pom.xml" afterPath="$PROJECT_DIR$/pom.xml" />
</list>
......@@ -23,8 +24,8 @@
<file leaf-file-name="pom.xml" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/pom.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="127">
<caret line="90" column="116" lean-forward="false" selection-start-line="90" selection-start-column="101" selection-end-line="90" selection-end-column="116" />
<state relative-caret-position="571">
<caret line="106" column="101" lean-forward="false" selection-start-line="106" selection-start-column="101" selection-end-line="106" selection-end-column="101" />
<folding />
</state>
</provider>
......@@ -45,6 +46,7 @@
<find>`</find>
<find>URI_REPORT_BY_SQL</find>
<find>show_sql</find>
<find>testreyun.cjxbwnaf9ore.rds.cn-northwest-1.amazonaws.com.cn</find>
</findStrings>
<replaceStrings>
<replace />
......@@ -829,15 +831,22 @@
<option name="project" value="LOCAL" />
<updated>1514873570341</updated>
</task>
<option name="localTasksCounter" value="7" />
<task id="LOCAL-00007" summary="test pom">
<created>1514873706283</created>
<option name="number" value="00007" />
<option name="presentableId" value="LOCAL-00007" />
<option name="project" value="LOCAL" />
<updated>1514873706284</updated>
</task>
<option name="localTasksCounter" value="8" />
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="58574000" />
<option name="totallyTimeSpent" value="58887000" />
</component>
<component name="ToolWindowManager">
<frame x="-8" y="-8" width="1382" height="744" extended-state="0" />
<editor active="true" />
<editor active="false" />
<layout>
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Nl-Palette" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
......@@ -858,10 +867,10 @@
<window_info id="Java Enterprise" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3289689" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.36497545" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.42880523" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
<window_info id="Spring" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.5581015" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.2647504" sideWeight="0.5" order="7" side_tool="false" content_ui="combo" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.2647504" sideWeight="0.5" order="7" side_tool="false" content_ui="combo" />
<window_info id="Bean Validation" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Web" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="4" side_tool="true" content_ui="tabs" />
<window_info id="Theme Preview" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
......@@ -1294,8 +1303,8 @@
</entry>
<entry file="file://$PROJECT_DIR$/pom.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="127">
<caret line="90" column="116" lean-forward="false" selection-start-line="90" selection-start-column="101" selection-end-line="90" selection-end-column="116" />
<state relative-caret-position="571">
<caret line="106" column="101" lean-forward="false" selection-start-line="106" selection-start-column="101" selection-end-line="106" selection-end-column="101" />
<folding />
</state>
</provider>
......
......@@ -88,7 +88,7 @@
<!--数据源配置-->
<datasource.driver>com.mysql.jdbc.Driver</datasource.driver>
<!--//office-->
<datasource.url>jdbc:mysql://testreyun.cjxbwnaf9ore.rds.cn-northwest-1.amazonaws.com.cn:3306/manager_preview?characterEncoding=utf-8</datasource.url>
<datasource.url>jdbc:mysql://testreyun.cjxbwnaf9ore.rds.cn-northwest-1.amazonaws.com.cn:3306/manager?characterEncoding=utf-8</datasource.url>
<datasource.username>reyuntest</datasource.username>
<datasource.password>reyuntest</datasource.password>
......@@ -104,7 +104,7 @@
<track.username>reyuntest</track.username>
<track.password>reyuntest</track.password>
<dmp.url>jdbc:mysql://testreyun.cjxbwnaf9ore.rds.cn-northwest-1.amazonaws.com.cn:3306/manager_preview?characterEncoding=utf-8</dmp.url>
<dmp.url>jdbc:mysql://testreyun.cjxbwnaf9ore.rds.cn-northwest-1.amazonaws.com.cn:3306/manager?characterEncoding=utf-8</dmp.url>
<dmp.username>reyuntest</dmp.username>
<dmp.password>reyuntest</dmp.password>
......
package util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.*;
/**
* 单节点Jedis.
* @author Administrator
*
*/
public class RedisUtilNew {
protected static Logger logger = LoggerFactory.getLogger(RedisUtilNew.class);
private static RedisUtilNew redisUtil = new RedisUtilNew();
private JedisPool pool;
//
// private ResourceBundle resourceBundle;
private RedisUtilNew() {
ResourceBundle resourceBundle = ResourceBundle.getBundle("redis");
pool = new JedisPool(resourceBundle.getString("redis.surl.host"),
Integer.valueOf(resourceBundle.getString("redis.surl.port")));
}
public static RedisUtilNew getInstance() {
return redisUtil;
}
public Map<String, String> hgetAll(String key) {
Map<String, String> result = new HashMap<String, String>();
Jedis jedis = pool.getResource();
result = jedis.hgetAll(key);
pool.returnResource(jedis);
return result;
}
public void hsetAll(String key, Map<String, String> map) {
Jedis jedis = pool.getResource();
jedis.hmset(key, map);
pool.returnResource(jedis);
}
public void delete(String key) {
Jedis jedis = pool.getResource();
jedis.del(key);
pool.returnResource(jedis);
}
/**
* 取值
*
* @param key
* @return
*/
public String get(String key) {
Jedis jedis = pool.getResource();
try {
String result = jedis.get(key);
if (result == null) {
return null;
}
return result;
} finally {
pool.returnResource(jedis);
}
}
/**
* 向redis中写入数据
* @param key
* @param value
*/
public void set(String key,String value)
{
Jedis jedis = pool.getResource();
jedis.set(key,value);
pool.returnResource(jedis);
}
public Long getExpireTime(String key)
{
Jedis jedis = pool.getResource();
Long m = jedis.ttl(key);
pool.returnResource(jedis);
return m;
}
/**
* 加锁.
*
* @param key
* @param expireTime
* 超时时间单位秒.
* @return 锁定的value,返回null值加锁失败,供释放锁时使用.
*/
public String tryLock(String key, int expireTime) {
Jedis jedis = pool.getResource();
try {
String value = Long.toString(System.currentTimeMillis() + (expireTime * 1000));
String result = jedis.set(key, value, "NX", "EX", expireTime);
if (result == null) {
return null;
}
return value;
} finally {
pool.returnResource(jedis);
}
}
public String expireValue(String key, String value, int expireTime)
{
Jedis jedis = pool.getResource();
try {
String result = jedis.set(key, value, "NX", "EX", expireTime);
if (result == null) {
return null;
}
return value;
} finally {
pool.returnResource(jedis);
}
}
public void releaseLock(String key) {
Jedis jedis = pool.getResource();
try {
Set<String> set = jedis.keys(key);
String[] kk = new String[set.size()];
jedis.del(set.toArray(kk));
} catch (Exception e) {
e.printStackTrace();
} finally {
pool.returnResource(jedis);
}
}
public static void main(String[] args) {
RedisUtilNew redisUtilNew = RedisUtilNew.getInstance();
//redisUtilNew.expireValue("test005","12",1000);
Long outtime = redisUtilNew.getExpireTime("test005");
redisUtilNew.delete("test005");
redisUtilNew.expireValue("test005","12",outtime.intValue());
System.out.println(outtime);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment