当前位置: 首页>>代码示例>>Java>>正文


Java ShardedJedis类代码示例

本文整理汇总了Java中redis.clients.jedis.ShardedJedis的典型用法代码示例。如果您正苦于以下问题:Java ShardedJedis类的具体用法?Java ShardedJedis怎么用?Java ShardedJedis使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ShardedJedis类属于redis.clients.jedis包,在下文中一共展示了ShardedJedis类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: scanHSet

import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
/**
 * 全局扫描hset
 *
 * @param match field匹配模式
 */
public List<Map.Entry<String, String>> scanHSet(String domain, String match) {
    try (ShardedJedis shardedJedis = shardedJedisPool.getResource()) {
        int cursor = 0;

        ScanParams scanParams = new ScanParams();
        scanParams.match(match);
        Jedis jedis = shardedJedis.getShard(domain);
        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;
    }
}
 
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:23,代码来源:RedisTemplate.java

示例2: saveFile

import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
@Override
public void saveFile(String fileLengthKey, String fileDataKey, String fileName, List<byte[]> values, long fileLength) {
    ShardedJedis shardedJedis = getShardedJedis();
    ShardedJedisPipeline pipelined = shardedJedis.pipelined();
    pipelined.hset(fileLengthKey.getBytes(), fileName.getBytes(), Longs.toByteArray(fileLength));
    Long blockSize = getBlockSize(fileLength);
    for (int i = 0; i < blockSize; i++) {
        pipelined.hset(fileDataKey.getBytes(), getBlockName(fileName, i), compressFilter(values.get(i)));
        if (i % Constants.SYNC_COUNT == 0) {
            pipelined.sync();
            pipelined = shardedJedis.pipelined();
        }
    }
    pipelined.sync();
    shardedJedis.close();
    values.clear();
}
 
开发者ID:shijiebei2009,项目名称:RedisDirectory,代码行数:18,代码来源:ShardedJedisPoolStream.java

示例3: checkCloseable

import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
@Test
public void checkCloseable() {
  List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>();
  shards.add(new JedisShardInfo(redis1.getHost(), redis1.getPort()));
  shards.add(new JedisShardInfo(redis2.getHost(), redis2.getPort()));
  shards.get(0).setPassword("foobared");
  shards.get(1).setPassword("foobared");

  ShardedJedis jedisShard = new ShardedJedis(shards);
  try {
    jedisShard.set("shard_closeable", "true");
  } finally {
    jedisShard.close();
  }

  for (Jedis jedis : jedisShard.getAllShards()) {
    assertTrue(!jedis.isConnected());
  }
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:20,代码来源:ShardedJedisTest.java

示例4: run

import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
public static <K> K run(String key, Executor<K> executor, Integer... expire) {
    ShardedJedis jedis = getJedis();
    if (jedis == null) {
        return null;
    }
    try {
        K result = executor.execute(jedis);
        if (jedis.exists(key)) {
            if (expire == null || expire.length == 0) {
                jedis.expire(key, EXPIRE);
            } else if (expire.length == 1) {
                jedis.expire(key, expire[0]);
            }
        }
        return result;
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    } finally {
        if (jedis != null) {
            jedis.close();
        }
    }
    return null;
}
 
开发者ID:tb544731152,项目名称:iBase4J,代码行数:25,代码来源:JedisTemplate.java

示例5: incr

import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
public final Long incr(final String key) {
	return jedisTemplate.run(key, new Executor<Long>() {
		public Long execute(ShardedJedis jedis) {
			return jedis.incr(key);
		}
	});
}
 
开发者ID:guokezheng,项目名称:automat,代码行数:8,代码来源:JedisHelper.java

示例6: zrangeWithScores

import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
public static final Set<Tuple> zrangeWithScores(final String key, final int start, final int end) {
	return JedisTemplate.run(key, new Executor<Set<Tuple>>() {
		public Set<Tuple> execute(ShardedJedis jedis) {
			return jedis.zrangeWithScores(key, start, end);
		}
	});
}
 
开发者ID:tb544731152,项目名称:iBase4J,代码行数:8,代码来源:JedisHelper.java

示例7: rpush

import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
public final Long rpush(final byte[] key, final byte[] string) {
	return jedisTemplate.run(key, new Executor<Long>() {
		public Long execute(ShardedJedis jedis) {
			return jedis.rpush(key, string);
		}
	});
}
 
开发者ID:guokezheng,项目名称:automat,代码行数:8,代码来源:JedisHelper.java

示例8: hdel

import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
public Long hdel(final byte[] key, final byte[] field) {
	return jedisTemplate.run(key, new Executor<Long>() {
		public Long execute(ShardedJedis jedis) {
			return jedis.hdel(key, field);
		}
	});
}
 
开发者ID:guokezheng,项目名称:automat,代码行数:8,代码来源:JedisHelper.java

示例9: sort

import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
public static final List<byte[]> sort(final byte[] key, final SortingParams sortingParameters) {
	return JedisTemplate.run(key, new Executor<List<byte[]>>() {
		public List<byte[]> execute(ShardedJedis jedis) {
			return jedis.sort(key, sortingParameters);
		}
	});
}
 
开发者ID:tb544731152,项目名称:iBase4J,代码行数:8,代码来源:JedisHelper.java

示例10: hdel

import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
public Long hdel(final byte[] key, final byte[] field) {
	return JedisTemplate.run(key, new Executor<Long>() {
		public Long execute(ShardedJedis jedis) {
			return jedis.hdel(key, field);
		}
	});
}
 
开发者ID:tb544731152,项目名称:iBase4J,代码行数:8,代码来源:JedisHelper.java

示例11: srandmember

import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
public final String srandmember(final String key) {
	return jedisTemplate.run(key, new Executor<String>() {
		public String execute(ShardedJedis jedis) {
			return jedis.srandmember(key);
		}
	});
}
 
开发者ID:guokezheng,项目名称:automat,代码行数:8,代码来源:JedisHelper.java

示例12: resetRequestRepeatCheck

import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
@Override
public void resetRequestRepeatCheck(Task task, Request request) {
    ShardedJedis jedis = jedisPool.getResource();
    try {
        jedis.srem(RedisKeys.getSetKey(task), request.key());
    } finally {
        jedis.close();
    }
}
 
开发者ID:brucezee,项目名称:jspider,代码行数:10,代码来源:ShardedRedisScheduler.java

示例13: zcard

import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
public static final Long zcard(final byte[] key) {
	return JedisTemplate.run(key, new Executor<Long>() {
		public Long execute(ShardedJedis jedis) {
			return jedis.zcard(key);
		}
	});
}
 
开发者ID:tb544731152,项目名称:iBase4J,代码行数:8,代码来源:JedisHelper.java

示例14: hmset

import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
public static final String hmset(final String key, final Map<String, String> hash) {
	return JedisTemplate.run(key, new Executor<String>() {
		public String execute(ShardedJedis jedis) {
			return jedis.hmset(key, hash);
		}
	});
}
 
开发者ID:tb544731152,项目名称:iBase4J,代码行数:8,代码来源:JedisHelper.java

示例15: ttl

import redis.clients.jedis.ShardedJedis; //导入依赖的package包/类
public final Long ttl(final byte[] key) {
	return jedisTemplate.run(key, new Executor<Long>() {
		public Long execute(ShardedJedis jedis) {
			return jedis.ttl(key);
		}
	});
}
 
开发者ID:guokezheng,项目名称:automat,代码行数:8,代码来源:JedisHelper.java


注:本文中的redis.clients.jedis.ShardedJedis类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。