<commit_before>package cache

import (
	"io/ioutil"
	"net/url"
	"os"
	"path"
	"sync"
)

type FileCacheSimple struct {
	mu  sync.Mutex
	dir string
}

func NewFileCacheSimple(d string) *FileCacheSimple {
	return &FileCacheSimple{dir: d}
}

func (c *FileCacheSimple) Write(key, value string) error {
	c.mu.Lock()
	defer c.mu.Unlock()
	filename := generateFilename(key)
	if err := atomicWriteFile(filename, c.dir, []byte(value)); err != nil {
		return err
	}
	return nil
}

func (c *FileCacheSimple) Read(key string) (string, bool) {<commit_msg>fix a non-existent directory bug<commit_after>package cache

import (
	"io/ioutil"
	"net/url"
	"os"
	"path"
	"sync"
)

type FileCacheSimple struct {
	mu  sync.Mutex
	dir string
}

func NewFileCacheSimple(d string) *FileCacheSimple {
	if _, err := os.Stat(d); os.IsNotExist(err) {
		if err := os.Mkdir(d, 0755); err != nil {
			panic(err)
		}
	}
	return &FileCacheSimple{dir: d}
}

func (c *FileCacheSimple) Write(key, value string) error {
	c.mu.Lock()
	defer c.mu.Unlock()
	filename := generateFilename(key)
	if err := atomicWriteFile(filename, c.dir, []byte(value)); err != nil {
		return err
	}
	return nil
}

func (c *FileCacheSimple) Read(key string) (string, bool) {
{'fraction_non_alphanumeric': 0.1434460016488046, 'fraction_numerical': 0.0032976092333058533, 'mean_word_length': 4.348017621145375, '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': '7107038', 'n_tokens_mistral': 473, 'n_tokens_neox': 464, 'n_words': 119}