<commit_before>package redis

import (
	redigo "github.com/garyburd/redigo/redis"
	cache_test "github.com/pierrre/imageserver/cache/test"
	"testing"
)

func TestGetSet(t *testing.T) {
	cache := createTestCache()
	defer cache.Close()

	cache_test.CacheTestGetSetAllImages(t, cache)
}

func createTestCache() *RedisCache {
	return &RedisCache{
		Pool: &redigo.Pool{
			Dial: func() (redigo.Conn, error) {
				return redigo.Dial("tcp", "localhost:6379")
			},
			MaxIdle: 50,
		},
	}
}
<commit_msg>improve RedisCache test for expiration<commit_after>package redis

import (
	redigo "github.com/garyburd/redigo/redis"
	cache_test "github.com/pierrre/imageserver/cache/test"
	"testing"
	"time"
)

func TestGetSet(t *testing.T) {
	cache := createTestCache()
	defer cache.Close()

	for _, expire := range []time.Duration{0, 1 * time.Minute} {
		cache.Expire = expire
		cache_test.CacheTestGetSetAllImages(t, cache)
	}
}

func createTestCache() *RedisCache {
	return &RedisCache{
		Pool: &redigo.Pool{
			Dial: func() (redigo.Conn, error) {
				return redigo.Dial("tcp", "localhost:6379")
			},
			MaxIdle: 50,
		},
	}
}

{'fraction_non_alphanumeric': 0.14465408805031446, 'fraction_numerical': 0.012578616352201259, 'mean_word_length': 4.434146341463415, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1747900', 'n_tokens_mistral': 475, 'n_tokens_neox': 430, 'n_words': 79}