package com.github.gabrielruiu.spring.cloud.config.redis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.util.StringUtils;

import java.util.HashSet;
import java.util.Set;

/**
 * @author Gabriel Mihai Ruiu (gabriel.ruiu@mail.com)
 */
public class RedisConfigKeysProvider {

    private StringRedisTemplate stringRedisTemplate;
    private RedisConfigKeysUtilities redisConfigKeysUtilities;

    @Autowired
    public RedisConfigKeysProvider(StringRedisTemplate stringRedisTemplate, RedisConfigKeysUtilities redisConfigKeysUtilities) {
        this.stringRedisTemplate = stringRedisTemplate;
        this.redisConfigKeysUtilities = redisConfigKeysUtilities;
    }

    public Set<String> getKeys(String application, String profiles, String label) {
        Set<String> applicationKeys = new HashSet<>();
        for (String profile : StringUtils.commaDelimitedListToSet(profiles)) {
            applicationKeys.addAll(stringRedisTemplate.keys(redisConfigKeysUtilities.redisConfigKeyTemplate(application, profile, label)));
        }
        return applicationKeys;
    }
}

@@ -278,16 +278,140 @@
 t;%0A%0A/**%0A
+ * Takes care of retrieving the keys from Redis, that match the pattern generated%0A * by %7B@link RedisConfigKeysUtilities%7D%0A *%0A
  * @auth

Add documentation to RedisConfigKeysProvider