package com.netease.mobile.commonUtil;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set; import javax.annotation.PostConstruct;
import javax.annotation.Resource; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisSentinelPool;
import redis.clients.jedis.ScanParams;
import redis.clients.jedis.ScanResult; @Service
public class SentinelJedisUtil {
private static Logger logger = LoggerFactory.getLogger(SentinelJedisUtil.class);
private static SentinelJedisUtil sentinelJedisUtil;
@Resource
private JedisSentinelPool jedisSentinelPool; @PostConstruct
public void init() {
sentinelJedisUtil = this;
sentinelJedisUtil.jedisSentinelPool = this.jedisSentinelPool; } /**
* 设置一个key的过期时间(单位:秒)
*
* @param key
* key值
* @param seconds
* 多少秒后过期
* @return 1:设置了过期时间 0:没有设置过期时间/不能设置过期时间
*/
public static long expire(String key, int seconds) {
if (key == null || key.equals("")) {
return 0;
} Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
return jedis.expire(key, seconds);
} catch (Exception ex) {
logger.error("EXPIRE error[key=" + key + " seconds=" + seconds
+ "]" + ex.getMessage(), ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return 0;
} /**
* 设置一个key在某个时间点过期
*
* @param key
* key值
* @param unixTimestamp
* unix时间戳,从1970-01-01 00:00:00开始到现在的秒数
* @return 1:设置了过期时间 0:没有设置过期时间/不能设置过期时间
*/
public static long expireAt(String key, int unixTimestamp) {
if (key == null || key.equals("")) {
return 0;
} Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
return jedis.expireAt(key, unixTimestamp);
} catch (Exception ex) {
logger.error("EXPIRE error[key=" + key + " unixTimestamp="
+ unixTimestamp + "]" + ex.getMessage(), ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return 0;
} /**
* 截断一个List
*
* @param key
* 列表key
* @param start
* 开始位置 从0开始
* @param end
* 结束位置
* @return 状态码
*/
public static String trimList(String key, long start, long end) {
if (key == null || key.equals("")) {
return "-";
}
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
return jedis.ltrim(key, start, end);
} catch (Exception ex) {
logger.error("LTRIM 出错[key=" + key + " start=" + start + " end="
+ end + "]" + ex.getMessage(), ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return "-";
} /**
* 检查Set长度
*
* @param key
* @return
*/
public static long countSet(String key) {
if (key == null) {
return 0;
}
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
return jedis.scard(key);
} catch (Exception ex) {
logger.error("countSet error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return 0;
} /**
* 添加到Set中(同时设置过期时间)
*
* @param key
* key值
* @param seconds
* 过期时间 单位s
* @param value
* @return
*/
public static boolean addSet(String key, int seconds, String... value) {
boolean result = addSet(key, value);
if (result) {
long i = expire(key, seconds);
return i == 1;
}
return false;
} /**
* 添加到Set中
*
* @param key
* @param value
* @return
*/
public static boolean addSet(String key, String... value) {
if (key == null || value == null) {
return false;
}
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
jedis.sadd(key, value);
return true;
} catch (Exception ex) {
logger.error("setList error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return false;
} /**
* @param key
* @param value
* @return 判断值是否包含在set中
*/
public static boolean containsInSet(String key, String value) {
if (key == null || value == null) {
return false;
}
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
return jedis.sismember(key, value);
} catch (Exception ex) {
logger.error("setList error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return false;
} /**
* 获取Set
*
* @param key
* @return
*/
public static Set<String> getSet(String key) {
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
return jedis.smembers(key);
} catch (Exception ex) {
logger.error("getList error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return null;
} /**
* 从set中删除value
*
* @param key
* @return
*/
public static boolean removeSetValue(String key, String... value) {
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
jedis.srem(key, value);
return true;
} catch (Exception ex) {
logger.error("getList error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return false;
} /**
* 从list中删除value 默认count 1
*
* @param key
* @param values
* 值list
* @return
*/
public static int removeListValue(String key, List<String> values) {
return removeListValue(key, 1, values);
} /**
* 从list中删除value
*
* @param key
* @param count
* @param values
* 值list
* @return
*/
public static int removeListValue(String key, long count,
List<String> values) {
int result = 0;
if (values != null && values.size() > 0) {
for (String value : values) {
if (removeListValue(key, count, value)) {
result++;
}
}
}
return result;
} /**
* 从list中删除value
*
* @param key
* @param count
* 要删除个数
* @param value
* @return
*/
public static boolean removeListValue(String key, long count, String value) {
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
jedis.lrem(key, count, value);
return true;
} catch (Exception ex) {
logger.error("getList error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return false;
} /**
* 截取List
*
* @param key
* @param start
* 起始位置
* @param end
* 结束位置
* @return
*/
public static List<String> rangeList(String key, long start, long end) {
if (key == null || key.equals("")) {
return null;
}
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
return jedis.lrange(key, start, end);
} catch (Exception ex) {
logger.error("rangeList 出错[key=" + key + " start=" + start
+ " end=" + end + "]" + ex.getMessage(), ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return null;
} /**
* 检查List长度
*
* @param key
* @return
*/
public static long countList(String key) {
if (key == null) {
return 0;
}
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
return jedis.llen(key);
} catch (Exception ex) {
logger.error("countList error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return 0;
} /**
* 添加到List中(同时设置过期时间)
*
* @param key
* key值
* @param seconds
* 过期时间 单位s
* @param value
* @return
*/
public static boolean addList(String key, int seconds, String... value) {
boolean result = addList(key, value);
if (result) {
long i = expire(key, seconds);
return i == 1;
}
return false;
} /**
* 添加到List
*
* @param key
* @param value
* @return
*/
public static boolean addList(String key, String... value) {
if (key == null || value == null) {
return false;
}
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
jedis.lpush(key, value);
return true;
} catch (Exception ex) {
logger.error("setList error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return false;
} /**
* 添加到List(只新增)
*
* @param key
* @param value
* @return
*/
public static boolean addList(String key, List<String> list) {
if (key == null || list == null || list.size() == 0) {
return false;
}
for (String value : list) {
addList(key, value);
}
return true;
} /**
* 获取List
*
* @param key
* @return
*/
public static List<String> getList(String key) {
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
return jedis.lrange(key, 0, -1);
} catch (Exception ex) {
logger.error("getList error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return null;
} /**
* 设置HashSet对象
*
* @param domain
* 域名
* @param key
* 键值
* @param value
* Json String or String value
* @return
*/
public static boolean setHSet(String domain, String key, String value) {
if (value == null)
return false;
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
jedis.hset(domain, key, value);
return true;
} catch (Exception ex) {
logger.error("setHSet error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return false;
} /**
* 获得HashSet对象
*
* @param domain
* 域名
* @param key
* 键值
* @return Json String or String value
*/
public static String getHSet(String domain, String key) {
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
return jedis.hget(domain, key);
} catch (Exception ex) {
logger.error("getHSet error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return null;
} /**
* 删除HashSet对象
*
* @param domain
* 域名
* @param key
* 键值
* @return 删除的记录数
*/
public static long delHSet(String domain, String key) {
Jedis jedis = null;
long count = 0;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
count = jedis.hdel(domain, key);
} catch (Exception ex) {
logger.error("delHSet error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return count;
} /**
* 删除HashSet对象
*
* @param domain
* 域名
* @param key
* 键值
* @return 删除的记录数
*/
public static long delHSet(String domain, String... key) {
Jedis jedis = null;
long count = 0;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
count = jedis.hdel(domain, key);
} catch (Exception ex) {
logger.error("delHSet error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return count;
} /**
* 判断key是否存在
*
* @param domain
* 域名
* @param key
* 键值
* @return
*/
public static boolean existsHSet(String domain, String key) {
Jedis jedis = null;
boolean isExist = false;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
isExist = jedis.hexists(domain, key);
} catch (Exception ex) {
logger.error("existsHSet error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return isExist;
} /**
* 全局扫描hset
*
* @param match
* field匹配模式
* @return
*/
public static List<Map.Entry<String, String>> scanHSet(String domain,
String match) {
Jedis jedis = null;
try {
int cursor = 0;
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
ScanParams scanParams = new ScanParams();
scanParams.match(match);
ScanResult<Map.Entry<String, String>> scanResult;
List<Map.Entry<String, String>> list = new ArrayList<Map.Entry<String, String>>();
do {
scanResult = jedis.hscan(domain, String.valueOf(cursor),
scanParams);
list.addAll(scanResult.getResult());
cursor = Integer.parseInt(scanResult.getStringCursor());
} while (cursor > 0);
return list;
} catch (Exception ex) {
logger.error("scanHSet error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return null;
} /**
* 全局扫描hset
*
* @param match
* field匹配模式
* @return
*/
public static Set<String> scan(String domain,
String match) {
Jedis jedis = null;
try {
int cursor = 0;
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
ScanParams scanParams = new ScanParams();
scanParams.match(match);
ScanResult<String> scanResult;
Set<String> retSet = new HashSet<String>();
do {
scanResult = jedis.scan(String.valueOf(cursor),
scanParams);
retSet.addAll(scanResult.getResult());
cursor = Integer.parseInt(scanResult.getStringCursor());
} while (cursor > 0);
return retSet;
} catch (Exception ex) {
logger.error("scanHSet error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return null;
} /**
* 返回 domain 指定的哈希集中所有字段的value值
*
* @param domain
* @return
*/ public static List<String> hvals(String domain) {
Jedis jedis = null;
List<String> retList = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
retList = jedis.hvals(domain);
} catch (Exception ex) {
logger.error("hvals error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return retList;
}
/**
* 返回 domain 指定的哈希集中所有字段的key值
*
* @param domain
* @return
*/ public static Set<String> hkeys(String domain) {
Jedis jedis = null;
Set<String> retList = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
retList = jedis.hkeys(domain);
} catch (Exception ex) {
logger.error("hkeys error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return retList;
} /**
* 返回 domain 指定的哈希key值总数
*
* @param domain
* @return
*/
public static long lenHset(String domain) {
Jedis jedis = null;
long retList = 0;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
retList = jedis.hlen(domain);
} catch (Exception ex) {
logger.error("hkeys error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return retList;
} /**
* 设置排序集合
*
* @param key
* @param score
* @param value
* @return
*/
public static boolean setSortedSet(String key, long score, String value) {
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
jedis.zadd(key, score, value);
return true;
} catch (Exception ex) {
logger.error("setSortedSet error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return false;
} /**
* 获得排序集合
*
* @param key
* @param startScore
* @param endScore
* @param orderByDesc
* @return
*/
public static Set<String> getSoredSet(String key, long startScore,
long endScore, boolean orderByDesc) {
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
if (orderByDesc) {
return jedis.zrevrangeByScore(key, endScore, startScore);
} else {
return jedis.zrangeByScore(key, startScore, endScore);
}
} catch (Exception ex) {
logger.error("getSoredSet error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return null;
} /**
* 计算排序长度
*
* @param key
* @param startScore
* @param endScore
* @return
*/
public static long countSoredSet(String key, long startScore, long endScore) {
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
Long count = jedis.zcount(key, startScore, endScore);
return count == null ? 0L : count;
} catch (Exception ex) {
logger.error("countSoredSet error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return 0L;
} /**
* 删除排序集合
*
* @param key
* @param value
* @return
*/
public static boolean delSortedSet(String key, String value) {
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
long count = jedis.zrem(key, value);
return count > 0;
} catch (Exception ex) {
logger.error("delSortedSet error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return false;
} /**
* 获得排序集合
*
* @param key
* @param startRange
* @param endRange
* @param orderByDesc
* @return
*/
public static Set<String> getSoredSetByRange(String key, int startRange,
int endRange, boolean orderByDesc) {
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
if (orderByDesc) {
return jedis.zrevrange(key, startRange, endRange);
} else {
return jedis.zrange(key, startRange, endRange);
}
} catch (Exception ex) {
logger.error("getSoredSetByRange error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return null;
} /**
* 获得排序打分
*
* @param key
* @return
*/
public static Double getScore(String key, String member) {
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
return jedis.zscore(key, member);
} catch (Exception ex) {
logger.error("getSoredSet error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return null;
} public static boolean set(String key, String value, int second) {
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
jedis.setex(key, second, value);
return true;
} catch (Exception ex) {
logger.error("set error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return false;
} public static boolean set(String key, String value) {
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
jedis.set(key, value);
return true;
} catch (Exception ex) {
logger.error("set error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return false;
} public static String get(String key, String defaultValue) {
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
return jedis.get(key) == null ? defaultValue : jedis
.get(key);
} catch (Exception ex) {
logger.error("get error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return defaultValue;
}
public static String get(String key) {
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
return jedis.get(key);
} catch (Exception ex) {
logger.error("get error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return null;
}
public static boolean del(String key) {
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
jedis.del(key);
return true;
} catch (Exception ex) {
logger.error("del error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return false;
} public static long incr(String key) {
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
return jedis.incr(key);
} catch (Exception ex) {
logger.error("incr error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return 0;
} public static long decr(String key) {
Jedis jedis = null;
try {
jedis = sentinelJedisUtil.jedisSentinelPool.getResource();
return jedis.decr(key);
} catch (Exception ex) {
logger.error("incr error.", ex);
returnBrokenResource(jedis);
} finally {
returnResource(jedis);
}
return 0;
} private static void returnBrokenResource(Jedis jedis) {
try {
sentinelJedisUtil.jedisSentinelPool.returnBrokenResource(jedis);
} catch (Exception e) {
logger.error("returnBrokenResource error.", e);
}
} private static void returnResource(Jedis jedis) {
try {
sentinelJedisUtil.jedisSentinelPool.returnResource(jedis);
} catch (Exception e) {
logger.error("returnResource error.", e);
}
} }

  

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
">
<bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">
<property name="maxTotal" value="${im.hs.server.redis.maxTotal}" />
<property name="minIdle" value="${im.hs.server.redis.minIdle}" />
<property name="maxWaitMillis" value="${im.hs.server.redis.maxWaitTime}" />
<property name="maxIdle" value="${im.hs.server.redis.maxIdle}" />
<property name="testOnBorrow" value="${im.hs.server.redis.testOnBorrow}" />
<property name="testOnReturn" value="true" />
<property name="testWhileIdle" value="true" />
</bean> <bean id="redisSentinel" class="redis.clients.jedis.JedisSentinelPool">
<constructor-arg index="0" value="mymaster" />
<constructor-arg index="1">
<set>
<value>10.165.124.19:26379</value>
<value>10.165.124.19:26378</value>
</set>
</constructor-arg>
<constructor-arg index="2" ref="poolConfig" /> </bean>

  

redis接入sentinelPool的配置的更多相关文章

  1. Redis Sentinel集群配置中的一些细节

    今天在配置Redis集群,用作Tomcat集群的缓存共享.关于Redis集群的配置网上有很多文章,这里只是记录一下我在配置过程中遇到的一些小的细节问题. 1. 关于Protected Mode的问题 ...

  2. [Linux]Linux下redis的安装及配置.

    在上一篇[Linux] linux下安装配置 zookeeper/redis/solr/tomcat/IK分词器 详细实例. 我们已经将redis所需tar包拷贝到了linux下的root 根目录下, ...

  3. Redis安装及主从配置(转)

    一.何为Redis redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链表).set(集合)和zset(有 ...

  4. Redis集群的配置

    [转]Redis集群的配置 一:memcache 和 Redis 对比总结 [memecache 特点] 1:速度最快(没有自测,但网上有详细的测试用例) 2:支持水平扩展,可以任意添加节点 [red ...

  5. redis安装与基本配置

    获取下载包 wget http://download.redis.io/releases/redis-2.8.24.tar.gz 解压和编译 tar -zxvf redis-2.8.24.tar.gz ...

  6. Redis安装及主从配置

    一.何为Redis redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链表).set(集合)和zset(有 ...

  7. redis的简单安装配置

    一.简介 Redis是一种高级key-value数据库,数据可以持久化,支持的数据类型很丰富,有字符串,哈希,链表,集合和有序集合5种数据类型 Redis支持在服务器端计算集合的并,交和补集(diff ...

  8. redis的单实例配置+web链接redis

    [root@cache01 src]# wget http://download.redis.io/redis-stable.tar.gz [root@cache01 src]# tar -xzvf ...

  9. Redis安装及基本配置

    一.Redis介绍 1.Redis是一个key-value存储系统 2.官方站点http://redis.io 3.Redis和Memcached类似,但支持数据持久化 4.支持更多value类型,除 ...

随机推荐

  1. iOS音效

    //AudioToolbox.framework是一套基于C语言的框架,使用它来播放音效其本质是将短音频注册到系统声音服务(System Sound Service) //System Sound S ...

  2. 40页PPT告诉你真正的"互联网+"

    点这里 40页PPT告诉你真正的"互联网+" 2015-04-06 网站分析公会 超过50万名互联网从业人士关注 互联网运营领域最具影响力自媒体 本文根据和君赵大伟关于互联网思维大 ...

  3. HDU 1116 || POJ 1386 || ZOJ 2016 Play on Words (欧拉回路+并查集)

    题目链接 题意 : 有很多门,每个门上有很多磁盘,每个盘上一个单词,必须重新排列磁盘使得每个单词的第一个字母与前一个单词的最后一个字母相同.给你一组单词问能不能排成上述形式. 思路 :把每个单词看成有 ...

  4. Linux网络编程9——对TCP与UDP的简易封装2.0

    具体生成动态库的操作及使用该动态库的操作请参见上篇博文.以下仅仅列出改进版本的代码. 代码 my_socket.h #ifndef __MY_SOCKET_H__ #define __MY_SOCKE ...

  5. java语言写文件内容

    import java.io.File;import java.io.FileWriter;import java.io.IOException; public static void main(St ...

  6. Linux Shell查看磁盘分区,内存使用,CPU使用率

    Linux Shell查看磁盘分区,内存使用,CPU使用率 #!/bin/bash #disk_used_rate Location=/dev/xvdb Disk_Used_Rate=$(df -h ...

  7. 图解TCP/IP读书笔记(一)

    图解TCP/IP读书笔记(一) 第一章 网络基础知识 本学期的信安概论课程中有大量的网络知识,其中TCP/IP占了相当大的比重,让我对上学期没有好好学习计算机网络这门课程深感后悔.在老师的推荐下开始阅 ...

  8. Centos环境下部署游戏服务器-SVN

    版本控制工具的文章已经被写滥了,所以本篇文章不想介绍如何安装Svn如何可视化操作这些东西.本篇文章讲述我自己对Svn的理解,以及在命令行下操作.为啥不应可视化界面?有两方面的原因,远程登录到服务器都是 ...

  9. QTableView带可编辑进度条

    main文件与上一个例子完全一致,也使用QStandardItemModel,关键是有这句:QStandardItem.setEditable(false);  继承QAbstractItemDele ...

  10. MakeObjectInstance的简单理解

    昨天把MakeObjectInstance的代码详细研究了一下,当然还有众多前辈高手们的帮助,终于大致搞明白了是怎么回事.但是给我顿悟的,不是高手们的帖子,而是来自我自己的一个疑惑,TObjectIn ...