// Path: src/main/java/com/mc/hibernate/memcached/keystrategy/KeyStrategy.java
// public interface KeyStrategy {
// 
//     String toKey(String regionName, long clearIndex, Object key);
// }
// 
// Path: src/main/java/com/mc/hibernate/memcached/keystrategy/Sha1KeyStrategy.java
// public class Sha1KeyStrategy extends DigestKeyStrategy {
//     protected String digest(String key) {
//         return StringUtils.sha1Hex(key);
//     }
// }


import com.mc.hibernate.memcached.keystrategy.KeyStrategy;
import com.mc.hibernate.memcached.keystrategy.Sha1KeyStrategy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
    private PropertiesHelper props;

    public Config(PropertiesHelper props) {
        this.props = props;
    }

    public int getCacheTimeSeconds(String cacheRegion) {
        int globalCacheTimeSeconds = props.getInt(PROP_PREFIX + CACHE_TIME_SECONDS, DEFAULT_CACHE_TIME_SECONDS);
        return props.getInt(cacheRegionPrefix(cacheRegion) + CACHE_TIME_SECONDS, globalCacheTimeSeconds);
    }

    public int getCacheLockTimeout(String cacheRegion) {
        int globalLockTimeout = props.getInt(PROP_PREFIX + LOCK_TIMEOUT_MS, DEFAULT_CACHE_LOCK_TIMEOUT_MS);
        return props.getInt(cacheRegionPrefix(cacheRegion) + LOCK_TIMEOUT_MS, globalLockTimeout);
    }

    public String getKeyStrategyName(String cacheRegion) {
        String globalKeyStrategy = props.get(PROP_PREFIX + KEY_STRATEGY, Sha1KeyStrategy.class.getName());
        return props.get(cacheRegionPrefix(cacheRegion) + KEY_STRATEGY, globalKeyStrategy);
    }

    private KeyStrategy instantiateKeyStrategy(String cls) {
        try {
            return (KeyStrategy) Class.forName(cls).newInstance();
        } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
            log.warn("Could not instantiate keyStrategy class " + cls + ". Will use default: Sha1KeyStrategy", e);
        }
        return new Sha1KeyStrategy();
    }

// Path: src/main/java/com/mc/hibernate/memcached/keystrategy/KeyStrategy.java
// public interface KeyStrategy {
// 
//     String toKey(String regionName, long clearIndex, Object key);
// }
// 
// Path: src/main/java/com/mc/hibernate/memcached/keystrategy/Sha1KeyStrategy.java
// public class Sha1KeyStrategy extends DigestKeyStrategy {
//     protected String digest(String key) {
//         return StringUtils.sha1Hex(key);
//     }
// }


// Path: src/main/java/com/mc/hibernate/memcached/Config.java
import com.mc.hibernate.memcached.keystrategy.KeyStrategy;
import com.mc.hibernate.memcached.keystrategy.Sha1KeyStrategy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

    private PropertiesHelper props;

    public Config(PropertiesHelper props) {
        this.props = props;
    }

    public int getCacheTimeSeconds(String cacheRegion) {
        int globalCacheTimeSeconds = props.getInt(PROP_PREFIX + CACHE_TIME_SECONDS, DEFAULT_CACHE_TIME_SECONDS);
        return props.getInt(cacheRegionPrefix(cacheRegion) + CACHE_TIME_SECONDS, globalCacheTimeSeconds);
    }

    public int getCacheLockTimeout(String cacheRegion) {
        int globalLockTimeout = props.getInt(PROP_PREFIX + LOCK_TIMEOUT_MS, DEFAULT_CACHE_LOCK_TIMEOUT_MS);
        return props.getInt(cacheRegionPrefix(cacheRegion) + LOCK_TIMEOUT_MS, globalLockTimeout);
    }

    public String getKeyStrategyName(String cacheRegion) {
        String globalKeyStrategy = props.get(PROP_PREFIX + KEY_STRATEGY, Sha1KeyStrategy.class.getName());
        return props.get(cacheRegionPrefix(cacheRegion) + KEY_STRATEGY, globalKeyStrategy);
    }

    private KeyStrategy instantiateKeyStrategy(String cls) {
        try {
            return (KeyStrategy) Class.forName(cls).newInstance();
        } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
            log.warn("Could not instantiate keyStrategy class " + cls + ". Will use default: Sha1KeyStrategy", e);
        }
        return new Sha1KeyStrategy();
    }

    public KeyStrategy getKeyStrategy(String cacheRegion) {