All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rebue.wheel.vertx.guice.RedisGuiceModule Maven / Gradle / Ivy

There is a newer version: 3.5.45
Show newest version
package rebue.wheel.vertx.guice;

import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import io.vertx.core.Vertx;
import io.vertx.core.json.JsonObject;
import io.vertx.redis.client.Redis;
import io.vertx.redis.client.RedisAPI;
import jakarta.inject.Named;
import jakarta.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
import rebue.wheel.vertx.util.RedisUtils;

@Slf4j
public class RedisGuiceModule extends AbstractModule {

    public RedisGuiceModule() {
        log.info("new RedisGuiceModule");
    }

    @Singleton
    @Provides
    Redis getRedis(final Vertx vertx, @Named("config") final JsonObject config) {
        log.info("RedisGuiceModule.getRedis");
        return RedisUtils.createRedisClient(vertx, config.getJsonObject("redis"));
    }

    @Singleton
    @Provides
    RedisAPI getRedisApi(Redis redis) {
        log.info("RedisGuiceModule.getRedisApi");
        return RedisAPI.api(redis);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy