<commit_before>package main

import (
	"flag"
	"fmt"
	"koding/databases/redis"
	"koding/tools/config"
	"koding/tools/logger"
	"time"

	redigo "github.com/garyburd/redigo/redis"
)

var (
	conf        *config.Config
	flagDebug   = flag.Bool("d", false, "Debug mode")
	flagProfile = flag.String("c", "", "Configuration profile from file")
)

func main() {
	flag.Parse()
	log := logger.New("Redis Expire Worker")

	if *flagProfile == "" {
		log.Fatal("Please specify profile via -c. Aborting.")
	}
	conf = config.MustConfig(*flagProfile)
	redisSess, err := redis.NewRedisSession(conf.Redis)
	if err != nil {
		panic(err)
	}
	log.Info("Expire script started with config: %v", *flagProfile)

	initialKey := fmt.Sprintf("%s-broker-client-*", conf.Environment)
	sesssionKeys, err := redigo.Strings(redisSess.Do("KEYS", initialKey))
	if err != nil {
		panic(err)
	}

	for _, sesssionKey := range sesssionKeys {
		log.Debug("sesssionKey %v", sesssionKey)
		time.Sleep(time.Millisecond * 10)
		err := redisSess.Expire(sesssionKey, time.Minute*59)
		if err != nil {
			log.Error("An error occured while sending expire req %v", err)
		}
	}
	log.Info("Expire script finished with config: %v", *flagProfile)<commit_msg>Redis/Tool: add documentation for package<commit_after>package main

import (
	"flag"
	"fmt"
	"koding/databases/redis"
	"koding/tools/config"
	"koding/tools/logger"
	"time"

	redigo "github.com/garyburd/redigo/redis"
)

var (
	conf        *config.Config
	flagDebug   = flag.Bool("d", false, "Debug mode")
	flagProfile = flag.String("c", "vagrant", "Configuration profile from file")
)

// This script is intended for adding expiration into redis keys
func main() {
	flag.Parse()
	log := logger.New("Redis Expire Worker")

	conf = config.MustConfig(*flagProfile)

	if *flagDebug {
		log.SetLevel(logger.DEBUG)
	} else {
		log.SetLevel(logger.INFO)
	}

	redisSess, err := redis.NewRedisSession(conf.Redis)
	if err != nil {
		panic(err)
	}
	log.Info("Expire script started with config: %v", *flagProfile)

	initialKey := fmt.Sprintf("%s-broker-client-*", conf.Environment)
	sesssionKeys, err := redigo.Strings(redisSess.Do("KEYS", initialKey))
	if err != nil {
		panic(err)
	}

	for _, sesssionKey := range sesssionKeys {
		log.Debug("sesssionKey %v", sesssionKey)
		time.Sleep(time.Millisecond * 10)
		err := redisSess.Expire(sesssionKey, time.Minute*59)
		if err != nil {
			log.Error("An error occured while sending expire req %v", err)
		}
	}
	log.Info("Expire script finished with config: %v", *flagProfile)
{'fraction_non_alphanumeric': 0.14962196577795464, 'fraction_numerical': 0.0031834460803820135, 'mean_word_length': 4.292631578947368, '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': '4655149', 'n_tokens_mistral': 981, 'n_tokens_neox': 925, 'n_words': 207}