Package ru.zinin.redis.session

Examples of ru.zinin.redis.session.RedisManager


     * @param commandLineParams Arguments map
     * @param ctx Tomcat context
     */
    @Override
    public void configureSessionStore(CommandLineParams commandLineParams, Context ctx){
        RedisManager redisManager = new RedisManager();
        redisManager.setDisableListeners(true);

        if(System.getenv("REDIS_URL") == null && System.getenv("REDISTOGO_URL") == null){
            System.out.println("WARNING: redis session store being used, but the required environment variable isn't set.");
            System.out.println("Redis session store is configured with REDIS_URL or REDISTOGO_URL");
        } else {
            try {
                URI redisUri = null;
                if(System.getenv("REDIS_URL") != null) {                   
                    redisUri = new URI(System.getenv("REDIS_URL"));                   
                } else {
                    redisUri = new URI(System.getenv("REDISTOGO_URL"));                   
                }

                if(redisUri.getHost() != null) {
                    redisManager.setRedisHostname(redisUri.getHost());
                }
                if(redisUri.getPort() != -1) {
                    redisManager.setRedisPort(redisUri.getPort());
                }
                if(redisUri.getPath() != null && redisUri.getPath().length() > 1) {
                    redisManager.setDbIndex(Integer.parseInt(redisUri.getPath().split("/")[1]));
                }
                if(redisUri.getUserInfo() != null) {
                    redisManager.setRedisPassword(redisUri.getUserInfo().substring(redisUri.getUserInfo().indexOf(":")+1));
                }
               
            } catch (URISyntaxException e){
                System.out.println("WARNING: redis session store environment variable invalid "+System.getenv("REDIS_URL"));
            }
View Full Code Here

TOP

Related Classes of ru.zinin.redis.session.RedisManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.