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


Java JedisCluster.hmset方法代码示例

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


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

示例1: main

import redis.clients.jedis.JedisCluster; //导入方法依赖的package包/类
@SuppressWarnings("resource")
public static void main(String[] args) {
	
	Set<HostAndPort> nodes = new HashSet<HostAndPort>();
	nodes.add(new HostAndPort("127.0.0.1", 7000));
	nodes.add(new HostAndPort("127.0.0.1", 7001));
	nodes.add(new HostAndPort("127.0.0.1", 7002));
	nodes.add(new HostAndPort("127.0.0.1", 7003));
	nodes.add(new HostAndPort("127.0.0.1", 7004));
	nodes.add(new HostAndPort("127.0.0.1", 7005));
	
	JedisCluster cluster = new JedisCluster(nodes, 5000);
	
	System.out.println(cluster.get("foo"));
	
	cluster.set("test", "6379");
	System.out.println(cluster.get("test"));
	
	Map<String, String> inviteePhone = new HashMap<String, String>();
	inviteePhone.put("inviterID", "1001");
	inviteePhone.put("status", "0");
	cluster.hmset("inviteePhone", inviteePhone);
	
	System.out.println(cluster.hget("inviteePhone", "inviterID"));
	System.out.println(cluster.hget("inviteePhone", "status"));
}
 
开发者ID:colddew,项目名称:mix-web,代码行数:27,代码来源:RedisClusterClient.java

示例2: storeJob

import redis.clients.jedis.JedisCluster; //导入方法依赖的package包/类
/**
 * Store a job in Redis
 *
 * @param jobDetail       the {@link JobDetail} object to be stored
 * @param replaceExisting if true, any existing job with the same group and name as the given job will be overwritten
 * @param jedis           a thread-safe Redis connection
 * @throws ObjectAlreadyExistsException
 */
@Override
@SuppressWarnings("unchecked")
public void storeJob(JobDetail jobDetail, boolean replaceExisting, JedisCluster jedis) throws ObjectAlreadyExistsException {
    final String jobHashKey = redisSchema.jobHashKey(jobDetail.getKey());
    final String jobDataMapHashKey = redisSchema.jobDataMapHashKey(jobDetail.getKey());
    final String jobGroupSetKey = redisSchema.jobGroupSetKey(jobDetail.getKey());

    if (!replaceExisting && jedis.exists(jobHashKey)) {
        throw new ObjectAlreadyExistsException(jobDetail);
    }

    jedis.hmset(jobHashKey, (Map<String, String>) mapper.convertValue(jobDetail, new TypeReference<HashMap<String, String>>() {
    }));
    if (jobDetail.getJobDataMap() != null && !jobDetail.getJobDataMap().isEmpty()) {
        jedis.hmset(jobDataMapHashKey, getStringDataMap(jobDetail.getJobDataMap()));
    }

    jedis.sadd(redisSchema.jobsSet(), jobHashKey);
    jedis.sadd(redisSchema.jobGroupsSet(), jobGroupSetKey);
    jedis.sadd(jobGroupSetKey, jobHashKey);
}
 
开发者ID:jlinn,项目名称:quartz-redis-jobstore,代码行数:30,代码来源:RedisClusterStorage.java

示例3: storeCalendar

import redis.clients.jedis.JedisCluster; //导入方法依赖的package包/类
/**
 * Store a {@link Calendar}
 *
 * @param name            the name of the calendar
 * @param calendar        the calendar object to be stored
 * @param replaceExisting if true, any existing calendar with the same name will be overwritten
 * @param updateTriggers  if true, any existing triggers associated with the calendar will be updated
 * @param jedis           a thread-safe Redis connection
 * @throws JobPersistenceException
 */
@Override
public void storeCalendar(String name, Calendar calendar, boolean replaceExisting, boolean updateTriggers, JedisCluster jedis) throws JobPersistenceException {
    final String calendarHashKey = redisSchema.calendarHashKey(name);
    if (!replaceExisting && jedis.exists(calendarHashKey)) {
        throw new ObjectAlreadyExistsException(String.format("Calendar with key %s already exists.", calendarHashKey));
    }
    Map<String, String> calendarMap = new HashMap<>();
    calendarMap.put(CALENDAR_CLASS, calendar.getClass().getName());
    try {
        calendarMap.put(CALENDAR_JSON, mapper.writeValueAsString(calendar));
    } catch (JsonProcessingException e) {
        throw new JobPersistenceException("Unable to serialize calendar.", e);
    }

    jedis.hmset(calendarHashKey, calendarMap);
    jedis.sadd(redisSchema.calendarsSet(), calendarHashKey);

    if (updateTriggers) {
        final String calendarTriggersSetKey = redisSchema.calendarTriggersSetKey(name);
        Set<String> triggerHashKeys = jedis.smembers(calendarTriggersSetKey);
        for (String triggerHashKey : triggerHashKeys) {
            OperableTrigger trigger = retrieveTrigger(redisSchema.triggerKey(triggerHashKey), jedis);
            long removed = jedis.zrem(redisSchema.triggerStateKey(RedisTriggerState.WAITING), triggerHashKey);
            trigger.updateWithNewCalendar(calendar, misfireThreshold);
            if (removed == 1) {
                setTriggerState(RedisTriggerState.WAITING, (double) trigger.getNextFireTime().getTime(), triggerHashKey, jedis);
            }
        }
    }
}
 
开发者ID:jlinn,项目名称:quartz-redis-jobstore,代码行数:41,代码来源:RedisClusterStorage.java

示例4: storeTrigger

import redis.clients.jedis.JedisCluster; //导入方法依赖的package包/类
/**
 * Store a trigger in redis
 *
 * @param trigger         the trigger to be stored
 * @param replaceExisting true if an existing trigger with the same identity should be replaced
 * @param jedis           a thread-safe Redis connection
 * @throws JobPersistenceException
 * @throws ObjectAlreadyExistsException
 */
@Override
public void storeTrigger(OperableTrigger trigger, boolean replaceExisting, JedisCluster jedis) throws JobPersistenceException {
    final String triggerHashKey = redisSchema.triggerHashKey(trigger.getKey());
    final String triggerGroupSetKey = redisSchema.triggerGroupSetKey(trigger.getKey());
    final String jobTriggerSetKey = redisSchema.jobTriggersSetKey(trigger.getJobKey());

    if (!(trigger instanceof SimpleTrigger) && !(trigger instanceof CronTrigger)) {
        throw new UnsupportedOperationException("Only SimpleTrigger and CronTrigger are supported.");
    }
    final boolean exists = jedis.exists(triggerHashKey);
    if (exists && !replaceExisting) {
        throw new ObjectAlreadyExistsException(trigger);
    }

    Map<String, String> triggerMap = mapper.convertValue(trigger, new TypeReference<HashMap<String, String>>() {
    });
    triggerMap.put(TRIGGER_CLASS, trigger.getClass().getName());

    jedis.hmset(triggerHashKey, triggerMap);
    jedis.sadd(redisSchema.triggersSet(), triggerHashKey);
    jedis.sadd(redisSchema.triggerGroupsSet(), triggerGroupSetKey);
    jedis.sadd(triggerGroupSetKey, triggerHashKey);
    jedis.sadd(jobTriggerSetKey, triggerHashKey);
    if (trigger.getCalendarName() != null && !trigger.getCalendarName().isEmpty()) {
        final String calendarTriggersSetKey = redisSchema.calendarTriggersSetKey(trigger.getCalendarName());
        jedis.sadd(calendarTriggersSetKey, triggerHashKey);
    }
    if (trigger.getJobDataMap() != null && !trigger.getJobDataMap().isEmpty()) {
        final String triggerDataMapHashKey = redisSchema.triggerDataMapHashKey(trigger.getKey());
        jedis.hmset(triggerDataMapHashKey, getStringDataMap(trigger.getJobDataMap()));
    }

    if (exists) {
        // We're overwriting a previously stored instance of this trigger, so clear any existing trigger state.
        unsetTriggerState(triggerHashKey, jedis);
    }

    Boolean triggerPausedResponse = jedis.sismember(redisSchema.pausedTriggerGroupsSet(), triggerGroupSetKey);
    Boolean jobPausedResponse = jedis.sismember(redisSchema.pausedJobGroupsSet(), redisSchema.jobGroupSetKey(trigger.getJobKey()));

    if (triggerPausedResponse || jobPausedResponse) {
        final long nextFireTime = trigger.getNextFireTime() != null ? trigger.getNextFireTime().getTime() : -1;
        final String jobHashKey = redisSchema.jobHashKey(trigger.getJobKey());
        if (jedis.sismember(redisSchema.blockedJobsSet(), jobHashKey)) {
            setTriggerState(RedisTriggerState.PAUSED_BLOCKED, (double) nextFireTime, triggerHashKey, jedis);
        } else {
            setTriggerState(RedisTriggerState.PAUSED, (double) nextFireTime, triggerHashKey, jedis);
        }
    } else if (trigger.getNextFireTime() != null) {
        setTriggerState(RedisTriggerState.WAITING, (double) trigger.getNextFireTime().getTime(), triggerHashKey, jedis);
    }
}
 
开发者ID:jlinn,项目名称:quartz-redis-jobstore,代码行数:62,代码来源:RedisClusterStorage.java


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