<commit_before><?php
class sspmod_redis_Store_Redis extends SimpleSAML_Store
{
    protected function __construct()
    {
        $config      = SimpleSAML_Configuration::getConfig('module_redis.php');
        $host        = $config->getString('host', 'localhost');
        $this->redis = new Predis\Client($host);
    }

    /**
     * Retrieve a value from Redis
     *
     * @param string $type The datatype
     * @param string $key  The key
     * @return mixed|NULL  The value
     */
    public function get($type, $key)
    {
        $redisKey = "simpleSAMLphp.$type.$key";
        $value = $this->redis->get($redisKey);

        return unserialize($value);
    }

    /**
     * Save a value to Redis
     *
     * @param string $type     The datatype
     * @param string $key      The key
     * @param mixed $value     The value
     * @param int|NULL $expire The expiration time (unix timestamp), or NULL if it never expires
     */
    public function set($type, $key, $value, $expire = null)
    {
        $redisKey = "simpleSAMLphp.$type.$key";
        $this->redis->set($redisKey, serialize($value));

        if (!is_null($expire)) {
            $this->redis->expire($redisKey, $expire);
        }
    }

    /**
     * Delete a value from Redis
     *<commit_msg>Added default expiration time on all keys<commit_after><?php
class sspmod_redis_Store_Redis extends SimpleSAML_Store
{
    protected function __construct()
    {
        $config      = SimpleSAML_Configuration::getConfig('module_redis.php');
        $host        = $config->getString('host', 'localhost');
        $this->redis = new Predis\Client($host);
        $this->lifeTime = $globalConfig->getInteger('session.duration', 28800); // Default 8 hours
    }

    /**
     * Retrieve a value from Redis
     *
     * @param string $type The datatype
     * @param string $key  The key
     * @return mixed|NULL  The value
     */
    public function get($type, $key)
    {
        $redisKey = "simpleSAMLphp.$type.$key";
        $value = $this->redis->get($redisKey);

        return unserialize($value);
    }

    /**
     * Save a value to Redis
     *
     * If no expiration time is given, then the expiration time is set to the
     * session duration.
     *
     * @param string $type     The datatype
     * @param string $key      The key
     * @param mixed $value     The value
     * @param int|NULL $expire The expiration time (unix timestamp), or NULL if it never expires
     */
    public function set($type, $key, $value, $expire = null)
    {
        $redisKey = "simpleSAMLphp.$type.$key";
        $this->redis->set($redisKey, serialize($value));

        if (is_null($expire)) {
            $expire = $this->lifeTime;
        }
        $this->redis->expire($redisKey, $expire);
    }

    /**
     * Delete a value from Redis
     *
{'fraction_non_alphanumeric': 0.12900951709552344, 'fraction_numerical': 0.0021149101163200562, 'mean_word_length': 2.2583237657864523, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4183985', 'n_tokens_mistral': 894, 'n_tokens_neox': 865, 'n_words': 228}