本文整理匯總了Java中redis.clients.jedis.Pipeline.del方法的典型用法代碼示例。如果您正苦於以下問題:Java Pipeline.del方法的具體用法?Java Pipeline.del怎麽用?Java Pipeline.del使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類redis.clients.jedis.Pipeline
的用法示例。
在下文中一共展示了Pipeline.del方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: remove
import redis.clients.jedis.Pipeline; //導入方法依賴的package包/類
@Override
public void remove(@NonNull String id) {
try (Jedis jedis = jedisSource.getJedis()) {
Map<String, String> userRolesById = jedis.hgetAll(userKey(id, ResourceType.ROLE));
Pipeline p = jedis.pipelined();
p.srem(allUsersKey(), id);
for (String roleName : userRolesById.keySet()) {
p.srem(roleKey(roleName), id);
}
for (ResourceType r : ResourceType.values()) {
p.del(userKey(id, r));
}
p.sync();
} catch (Exception e) {
log.error("Storage exception reading " + id + " entry.", e);
}
}
示例2: removeCalendar
import redis.clients.jedis.Pipeline; //導入方法依賴的package包/類
/**
* Remove (delete) the <code>{@link org.quartz.Calendar}</code> with the given name.
* @param calendarName the name of the calendar to be removed
* @param jedis a thread-safe Redis connection
* @return true if a calendar with the given name was found and removed
*/
@Override
public boolean removeCalendar(String calendarName, Jedis jedis) throws JobPersistenceException {
final String calendarTriggersSetKey = redisSchema.calendarTriggersSetKey(calendarName);
if(jedis.scard(calendarTriggersSetKey) > 0){
throw new JobPersistenceException(String.format("There are triggers pointing to calendar %s, so it cannot be removed.", calendarName));
}
final String calendarHashKey = redisSchema.calendarHashKey(calendarName);
Pipeline pipe = jedis.pipelined();
Response<Long> deleteResponse = pipe.del(calendarHashKey);
pipe.srem(redisSchema.calendarsSet(), calendarHashKey);
pipe.sync();
return deleteResponse.get() == 1;
}
示例3: registerFakeSession
import redis.clients.jedis.Pipeline; //導入方法依賴的package包/類
private void registerFakeSession(int count, User user) {
//Clean all sessions
Jedis jedis = JedisFactory.getJedis();
Pipeline pipeline = jedis.pipelined();
Set<byte[]> strs = jedis.keys("*".getBytes());
for ( byte[] key : strs ) {
pipeline.del(key);
}
pipeline.sync();
UserId userId = user.get_id();
SessionKey sessionKey = SessionKey.createSessionKeyFromRandomString();
user.setSessionKey(sessionKey);
//Store it with machineid to redis
jedis = JedisFactory.getJedis();
pipeline = jedis.pipelined();
for ( int i=0; i<count; i++ ) {
pipeline.hset(sessionKey.toString(), SessionManager.H_MACHINE_KEY, "localhost:10000");
pipeline.hset(userId.toString(), SessionManager.H_MACHINE_KEY, "localhost:10000");
pipeline.hset(userId.toString(), SessionManager.H_SESSION_KEY, sessionKey.toString());
}
pipeline.sync();
}
示例4: resetChannels
import redis.clients.jedis.Pipeline; //導入方法依賴的package包/類
public void resetChannels(final Set<String> channels) {
Handle handle = rdbi.open();
try {
Pipeline pipeline = handle.jedis().pipelined();
for (String channel : channels) {
pipeline.del(channel + ":queue");
pipeline.del(channel + ":depth");
}
pipeline.sync();
} finally {
handle.close();
}
}
示例5: doDeleteRecord
import redis.clients.jedis.Pipeline; //導入方法依賴的package包/類
private void doDeleteRecord(Record record, List<ErrorRecord> tempRecords, Pipeline pipeline, String key)
throws StageException {
if (!StringUtils.isEmpty(key)) {
pipeline.del(key);
tempRecords.add(new ErrorRecord(record, "Delete", key, ""));
} else {
LOG.error(Errors.REDIS_09.getMessage(), key);
errorRecordHandler.onError(
new OnRecordErrorException(
record,
Errors.REDIS_09
)
);
}
}
示例6: deleteAllKeys
import redis.clients.jedis.Pipeline; //導入方法依賴的package包/類
/**
* Use it with caution.
* It delete all the keys from Redis
*/
public static final void deleteAllKeys(Jedis jedis) {
Pipeline pipeline = jedis.pipelined();
Set<byte[]> bytes = jedis.keys("*".getBytes());
for ( byte[] key : bytes ) {
pipeline.del(key);
}
pipeline.sync();
}
示例7: testClean
import redis.clients.jedis.Pipeline; //導入方法依賴的package包/類
public void testClean() {
com.xinqihd.sns.gameserver.jedis.Jedis jedis = JedisFactory.getJedis();
Set<String> strs = jedis.keys("*");
Pipeline pipeline = jedis.pipelined();
for ( String key : strs ) {
pipeline.del(key);
}
pipeline.sync();
}
示例8: clobberThings
import redis.clients.jedis.Pipeline; //導入方法依賴的package包/類
@BeforeMethod
public void clobberThings() {
final RDBI rdbi = new RDBI(new JedisPool("localhost"));
try (final Handle h = rdbi.open()) {
final Set<String> keys = h.jedis().keys(cachePrefix + "*");
final Pipeline pipeline = h.jedis().pipelined();
for (final String key : keys) {
pipeline.del(key);
}
pipeline.sync();
}
}
示例9: setLastEntries
import redis.clients.jedis.Pipeline; //導入方法依賴的package包/類
@Override
public void setLastEntries(Feed feed, List<String> entries) {
try (Jedis jedis = pool.getResource()) {
String key = buildRedisEntryKey(feed);
Pipeline pipe = jedis.pipelined();
pipe.del(key);
for (String entry : entries) {
pipe.sadd(key, entry);
}
pipe.expire(key, (int) TimeUnit.DAYS.toSeconds(7));
pipe.sync();
}
}
示例10: setUserRootCategory
import redis.clients.jedis.Pipeline; //導入方法依賴的package包/類
@Override
public void setUserRootCategory(User user, Category category) {
try (Jedis jedis = pool.getResource()) {
String key = buildRedisUserRootCategoryKey(user);
Pipeline pipe = jedis.pipelined();
pipe.del(key);
pipe.set(key, MAPPER.writeValueAsString(category));
pipe.expire(key, (int) TimeUnit.MINUTES.toSeconds(30));
pipe.sync();
} catch (JsonProcessingException e) {
log.error(e.getMessage(), e);
}
}
示例11: setUnreadCount
import redis.clients.jedis.Pipeline; //導入方法依賴的package包/類
@Override
public void setUnreadCount(FeedSubscription sub, UnreadCount count) {
try (Jedis jedis = pool.getResource()) {
String key = buildRedisUnreadCountKey(sub);
Pipeline pipe = jedis.pipelined();
pipe.del(key);
pipe.set(key, MAPPER.writeValueAsString(count));
pipe.expire(key, (int) TimeUnit.MINUTES.toSeconds(30));
pipe.sync();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
示例12: invalidateUserRootCategory
import redis.clients.jedis.Pipeline; //導入方法依賴的package包/類
@Override
public void invalidateUserRootCategory(User... users) {
try (Jedis jedis = pool.getResource()) {
Pipeline pipe = jedis.pipelined();
if (users != null) {
for (User user : users) {
String key = buildRedisUserRootCategoryKey(user);
pipe.del(key);
}
}
pipe.sync();
}
}
示例13: invalidateUnreadCount
import redis.clients.jedis.Pipeline; //導入方法依賴的package包/類
@Override
public void invalidateUnreadCount(FeedSubscription... subs) {
try (Jedis jedis = pool.getResource()) {
Pipeline pipe = jedis.pipelined();
if (subs != null) {
for (FeedSubscription sub : subs) {
String key = buildRedisUnreadCountKey(sub);
pipe.del(key);
}
}
pipe.sync();
}
}
示例14: put
import redis.clients.jedis.Pipeline; //導入方法依賴的package包/類
@Override
public RedisPermissionsRepository put(@NonNull UserPermission permission) {
Map<ResourceType, Map<String, String>> resourceTypeToRedisValue =
new HashMap<>(ResourceType.values().length);
permission
.getAllResources()
.forEach(resource -> {
try {
resourceTypeToRedisValue
.computeIfAbsent(resource.getResourceType(), key -> new HashMap<>())
.put(resource.getName(), objectMapper.writeValueAsString(resource));
} catch (JsonProcessingException jpe) {
log.error("Serialization exception writing " + permission.getId() + " entry.", jpe);
}
});
try (Jedis jedis = jedisSource.getJedis()) {
Pipeline deleteOldValuesPipeline = jedis.pipelined();
Pipeline insertNewValuesPipeline = jedis.pipelined();
String userId = permission.getId();
insertNewValuesPipeline.sadd(allUsersKey(), userId);
permission.getRoles().forEach(role -> insertNewValuesPipeline.sadd(roleKey(role), userId));
for (ResourceType r : ResourceType.values()) {
String userResourceKey = userKey(userId, r);
deleteOldValuesPipeline.del(userResourceKey);
Map<String, String> redisValue = resourceTypeToRedisValue.get(r);
if (redisValue != null && !redisValue.isEmpty()) {
insertNewValuesPipeline.hmset(userResourceKey, redisValue);
}
}
deleteOldValuesPipeline.sync();
insertNewValuesPipeline.sync();
} catch (Exception e) {
log.error("Storage exception writing " + permission.getId() + " entry.", e);
}
return this;
}
示例15: removeJob
import redis.clients.jedis.Pipeline; //導入方法依賴的package包/類
/**
* Remove the given job from Redis
* @param jobKey the job to be removed
* @param jedis a thread-safe Redis connection
* @return true if the job was removed; false if it did not exist
*/
@Override
public boolean removeJob(JobKey jobKey, Jedis jedis) throws JobPersistenceException {
final String jobHashKey = redisSchema.jobHashKey(jobKey);
final String jobBlockedKey = redisSchema.jobBlockedKey(jobKey);
final String jobDataMapHashKey = redisSchema.jobDataMapHashKey(jobKey);
final String jobGroupSetKey = redisSchema.jobGroupSetKey(jobKey);
final String jobTriggerSetKey = redisSchema.jobTriggersSetKey(jobKey);
Pipeline pipe = jedis.pipelined();
// remove the job and any associated data
Response<Long> delJobHashKeyResponse = pipe.del(jobHashKey);
// remove the blocked job key
pipe.del(jobBlockedKey);
// remove the job's data map
pipe.del(jobDataMapHashKey);
// remove the job from the set of all jobs
pipe.srem(redisSchema.jobsSet(), jobHashKey);
// remove the job from the set of blocked jobs
pipe.srem(redisSchema.blockedJobsSet(), jobHashKey);
// remove the job from its group
pipe.srem(jobGroupSetKey, jobHashKey);
// retrieve the keys for all triggers associated with this job, then delete that set
Response<Set<String>> jobTriggerSetResponse = pipe.smembers(jobTriggerSetKey);
pipe.del(jobTriggerSetKey);
Response<Long> jobGroupSetSizeResponse = pipe.scard(jobGroupSetKey);
pipe.sync();
if(jobGroupSetSizeResponse.get() == 0){
// The group now contains no jobs. Remove it from the set of all job groups.
jedis.srem(redisSchema.jobGroupsSet(), jobGroupSetKey);
}
// remove all triggers associated with this job
pipe = jedis.pipelined();
for (String triggerHashKey : jobTriggerSetResponse.get()) {
// get this trigger's TriggerKey
final TriggerKey triggerKey = redisSchema.triggerKey(triggerHashKey);
final String triggerGroupSetKey = redisSchema.triggerGroupSetKey(triggerKey);
unsetTriggerState(triggerHashKey, jedis);
// remove the trigger from the set of all triggers
pipe.srem(redisSchema.triggersSet(), triggerHashKey);
// remove the trigger's group from the set of all trigger groups
pipe.srem(redisSchema.triggerGroupsSet(), triggerGroupSetKey);
// remove this trigger from its group
pipe.srem(triggerGroupSetKey, triggerHashKey);
// delete the trigger
pipe.del(triggerHashKey);
}
pipe.sync();
return delJobHashKeyResponse.get() == 1;
}