<commit_before>package sessions

import (
	"bytes"
	"encoding/gob"
	"github.com/garyburd/redigo/redis"
	"net/http"
)

var sessionExpire = 86400 * 30

type RedisStore struct {
	*http.Cookie
	*redis.Pool
	exitChannel   chan int
	queryChannel  chan *RedisQuery
	DefaultMaxAge int
}

func NewRedisStore(network, address, password string) *RedisStore {
	con := func() (redis.Conn, error) {
		c, err := redis.Dial(network, address)
		if err != nil {
			return nil, err
		}
		if password != "" {
			if _, err := c.Do("AUTH", password); err != nil {
				c.Close()
				return nil, err
			}
		}
		return c, err
	}
	return &RedisStore{
		Pool: redis.NewPool(con, 3),
		Cookie: &http.Cookie{
			Path:   "/",
			MaxAge: sessionExpire,
		},
		DefaultMaxAge: sessionExpire,
	}
}

type RedisQuery struct {
	Action        string
	Options       []interface{}
	resultChannel chan *QueryResult
}

type QueryResult struct {
	Err   error
	Value interface{}
}
<commit_msg>init channel<commit_after>package sessions

import (
	"bytes"
	"encoding/gob"
	"github.com/garyburd/redigo/redis"
	"net/http"
)

var sessionExpire = 86400 * 30

type RedisStore struct {
	*http.Cookie
	*redis.Pool
	exitChannel   chan int
	queryChannel  chan *RedisQuery
	DefaultMaxAge int
}

func NewRedisStore(network, address, password string) *RedisStore {
	con := func() (redis.Conn, error) {
		c, err := redis.Dial(network, address)
		if err != nil {
			return nil, err
		}
		if password != "" {
			if _, err := c.Do("AUTH", password); err != nil {
				c.Close()
				return nil, err
			}
		}
		return c, err
	}
	return &RedisStore{
		Pool:         redis.NewPool(con, 3),
		exitChannel:  make(chan int),
		queryChannel: make(chan *RedisQuery),
		Cookie: &http.Cookie{
			Path:   "/",
			MaxAge: sessionExpire,
		},
		DefaultMaxAge: sessionExpire,
	}
}

type RedisQuery struct {
	Action        string
	Options       []interface{}
	resultChannel chan *QueryResult
}

type QueryResult struct {
	Err   error
	Value interface{}
}

{'fraction_non_alphanumeric': 0.12291350531107739, 'fraction_numerical': 0.008093070308548306, 'mean_word_length': 3.2721382289416847, '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': '3457515', 'n_tokens_mistral': 797, 'n_tokens_neox': 716, 'n_words': 183}