鉴于redis的list,hash,set,string等类型的操作,很多人都已经熟练使用,就简单介绍一下动态参数修改,主从切换,持久化设置,系统信息监控.Redis 中文文档里面, 有控制台操作的详细的说明,http://redis.readthedocs.org/en/latest/index.html下面的内容是java的api应用.
- package redis;
-
- import java.util.List;
- import java.util.UUID;
-
- import redis.clients.jedis.Jedis;
- import redis.clients.jedis.ShardedJedis;
- import redis.clients.util.ShardInfo;
-
- /**
- * @author Andy
- */
- public class RedisMasterSlaveTest {
-
- private static final String HOST = "";
- private static final int PORT = 0;
-
- /**
- * 添加测试数据
- */
- private static void setData(Jedis jedis) {
-
- for (int i = 0; i < 100; i++) {
- final String a = UUID.randomUUID().toString();
- jedis.set(a, a);
- }
- }
-
- /**
- * dbsize 数据库key总数
- */
- private static long getDBSize(Jedis jedis) {
- return jedis.dbSize();
- }
-
- /**
- * 查询持久化策略
- */
- private static List<String> getSaveConfig(Jedis jedis) {
- return jedis.configGet("save");
- }
-
- /**
- * 设置持久化策略
- */
- private static String setSaveConfig(Jedis jedis) {
- String celue_1 = "800 1";
- String celue_2 = "400 2";
- return jedis.configSet("save", celue_1 + " " + celue_2);
- }
-
- /**
- * 阻塞IO后持久化数据然后关闭redis (shutdown)
- */
- private static String shutdown(Jedis jedis) {
- return jedis.shutdown();
- }
-
- /**
- * 将此redis设置为master主库
- */
- private static String slaveofNoOne(Jedis jedis) {
- return jedis.slaveofNoOne();
- }
-
- /**
- * 将此redis根据host/port设置为slaveof从库
- */
- private static String slaveof(Jedis jedis) {
- return jedis.slaveof(HOST, PORT);
- }
-
- /**
- * 查询redis的info信息
- */
- private static String info(Jedis jedis) {
- return jedis.info();
- }
-
- /**
- * select?
- */
- private static String select(Jedis jedis) {
- return jedis.select(1);
- }
-
- }
|
有一个 重置系统参数 的方法,测试了一下,没用.所以就没写.select方法,没使用过,有使用过的朋友可以跟帖介绍一下~更多关于Redis的详细信息,或者下载地址请点这里 Oracle查询月初和月底时间使用RMAN的Duplicate功能创建物理DataGuard相关资讯 Redis
- Redis 非关系型数据库 ( Nosql ) (07月01日)
- Java中使用Jedis操作Redis (04月08日)
- 在Ubuntu 14.04下安装Redis (01月31日)
| - 关于 Redis的订阅发布 (04月15日)
- MongoDB仲裁节点的理解及Memcached (02月13日)
- 关于redis中的Replication (01月29日)
|
本文评论 查看全部评论 (0)