Java Code Examples for io.jboot.Jboot#getRedis()

The following examples show how to use io.jboot.Jboot#getRedis() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedisTestController.java    From jboot with Apache License 2.0 6 votes vote down vote up
public void show() {

        String key = getPara("key");
        if (StrUtil.isBlank(key)) {
            renderText("key is empty. ");
            return;
        }

        JbootRedis redis = Jboot.getRedis();
        if (redis == null) {
            renderText("can not get redis, maybe redis config is error.");
            return;
        }

        Object object = redis.get(key);
        renderText("value : " + object);

    }
 
Example 2
Source File: RedisTestController.java    From jboot with Apache License 2.0 6 votes vote down vote up
public void set() {

        String key = getPara("key");
        if (StrUtil.isBlank(key)) {
            renderText("key is empty. ");
            return;
        }

        String value = getPara("value");
        if (StrUtil.isBlank(value)) {
            renderText("value is empty. ");
            return;
        }

        JbootRedis redis = Jboot.getRedis();
        if (redis == null) {
            renderText("can not get redis, maybe redis config is error.");
            return;
        }

        redis.set(key,value);
        renderText("set ok " );
    }
 
Example 3
Source File: RedisTestController.java    From jboot with Apache License 2.0 6 votes vote down vote up
public void del() {

        String key = getPara("key");
        if (StrUtil.isBlank(key)) {
            renderText("key is empty. ");
            return;
        }

        JbootRedis redis = Jboot.getRedis();
        if (redis == null) {
            renderText("can not get redis, maybe redis config is error.");
            return;
        }

        redis.del(key);
        renderText("del ok " );

    }
 
Example 4
Source File: JbootRedisLock.java    From jboot with Apache License 2.0 5 votes vote down vote up
/**
 * 创建redis分布式锁
 *
 * @param lockName 锁的名称
 */
public JbootRedisLock(String lockName) {
    if (lockName == null) {
        throw new NullPointerException("lockName must not null !");
    }
    this.lockName = lockName;
    this.redis = Jboot.getRedis();
}
 
Example 5
Source File: JbootRedisLock.java    From jboot with Apache License 2.0 5 votes vote down vote up
/**
 * 创建redis分布式锁
 *
 * @param lockName     锁名称
 * @param timeoutMsecs 获取锁的时候,等待时长
 */
public JbootRedisLock(String lockName, long timeoutMsecs) {
    if (lockName == null) {
        throw new NullPointerException("lockName must not null !");
    }
    this.lockName = lockName;
    this.timeoutMsecs = timeoutMsecs;
    this.redis = Jboot.getRedis();
}
 
Example 6
Source File: JbootRedismqImpl.java    From jboot with Apache License 2.0 5 votes vote down vote up
public JbootRedismqImpl() {
    super();
    JbootmqRedisConfig redisConfig = Jboot.config(JbootmqRedisConfig.class);
    if (redisConfig.isConfigOk()) {
        redis = JbootRedisManager.me().getRedis(redisConfig);
    } else {
        redis = Jboot.getRedis();
    }

    if (redis == null) {
        throw new JbootIllegalConfigException("can not use redis mq (redis mq is default), " +
                "please config jboot.redis.host=your-host , or use other mq component. ");
    }
}
 
Example 7
Source File: JbootDistributedRunnable.java    From jboot with Apache License 2.0 5 votes vote down vote up
public JbootDistributedRunnable() {

        this.redis = Jboot.getRedis();
        this.key = "jbootRunnable:" + this.getClass().getName();

        if (redis == null) {
            LOG.warn("redis is null, " +
                    "can not use @EnableDistributedRunnable in your Class[" + this.getClass().getName() + "], " +
                    "or config redis info in jboot.properties");
        }

    }
 
Example 8
Source File: JbootDistributedRunnable.java    From jboot with Apache License 2.0 5 votes vote down vote up
public JbootDistributedRunnable(Runnable runnable) {
    this.runnable = runnable;
    this.key = "jbootRunnable:" + runnable.getClass().getName();
    this.redis = Jboot.getRedis();
    if (redis == null) {
        LOG.warn("redis is null, " +
                "can not use @EnableDistributedRunnable in your Class[" + runnable.getClass().getName() + "], " +
                "or config redis info in jboot.properties");
    }
}
 
Example 9
Source File: JbootDistributedRunnable.java    From jboot with Apache License 2.0 5 votes vote down vote up
public JbootDistributedRunnable(Runnable runnable, int expire) {
    this.expire = (expire - 1) * 1000;
    this.runnable = runnable;
    this.key = "jbootRunnable:" + runnable.getClass().getName();
    this.redis = Jboot.getRedis();
    if (redis == null) {
        LOG.warn("redis is null, " +
                "can not use @EnableDistributedRunnable in your Class[" + runnable.getClass().getName() + "], " +
                "or config redis info in jboot.properties");
    }
}
 
Example 10
Source File: JbootRedisCacheImpl.java    From jboot with Apache License 2.0 5 votes vote down vote up
public JbootRedisCacheImpl() {
    JbootRedisCacheConfig redisConfig = Jboot.config(JbootRedisCacheConfig.class);
    if (redisConfig.isConfigOk()) {
        redis = JbootRedisManager.me().getRedis(redisConfig);
    } else {
        redis = Jboot.getRedis();
    }

    if (redis == null) {
        throw new JbootIllegalConfigException("can not get redis, please check your jboot.properties , please correct config jboot.cache.redis.host or jboot.redis.host ");
    }
}