<commit_before>package gocache


import (
    cache "github.com/pmylund/go-cache"
    "time"
)

// Wraps github.com/pmylund/go-cache into our local cache interface.


type GoCache struct {
    Cache *cache.Cache
}

// Creates a new GoCache with the given intervals
// defaultExpiration = 0 is never expire
// cleanupInterval = 0 is never attempt to clean up expired 
func New(defaultExpirationSeconds, cleanupIntervalSeconds int) *GoCache {
    return &GoCache{
        Cache : cache.New(time.Duration(defaultExpirationSeconds) * time.Second, time.Duration(cleanupIntervalSeconds) * time.Second),
    }
}

func (this *GoCache) Set(key string, value []byte, expireSeconds int) {
    this.Cache.Set(key, value, time.Duration(expireSeconds)*time.Second)
}


    // Sets the value if and only if there is no value associated with this key
func (this *GoCache) SetIfAbsent(key string, value []byte, expireSeconds int) bool {
    err := this.Cache.Add(key, value, time.Duration(expireSeconds)*time.Second)
    return err == nil
}
    
    // Deletes the value at the requested key
func (this *GoCache) Delete(key string) bool {
    this.Cache.Delete(key)
}

    // Gets the value at the requested key
func (this *GoCache) Get(key string) ([]byte, bool) {
    v, ok := this.Cache.Get(key)
    if !ok {
        return make([]byte,0), false
    }
    bt, ok := v.([]byte)
    return bt, ok
}

    // // Increment the key by val (val is allowed to be negative)
    // // in most implementation expireSeconds will be from the first increment, but users should not count on that.
    // // if no value is a present it should be added.  
    // // If a value is present which is not a number an error should be returned.
    // Inc(key string, val int64, expireSeconds int) (int64, error)<commit_msg>add first cache provider (local cache)<commit_after>package gocache


import (
    cache "github.com/pmylund/go-cache"
    "time"
    "sync"
)

// Wraps github.com/pmylund/go-cache into our local cache interface.


type GoCache struct {
    Cache *cache.Cache
    lock sync.Mutex
}

// Creates a new GoCache with the given intervals
// defaultExpiration = 0 is never expire
// cleanupInterval = 0 is never attempt to clean up expired 
func New(defaultExpirationSeconds, cleanupIntervalSeconds int) *GoCache {
    return &GoCache{
        Cache : cache.New(time.Duration(defaultExpirationSeconds) * time.Second, time.Duration(cleanupIntervalSeconds) * time.Second),
    }
}

func (this *GoCache) Set(key string, value []byte, expireSeconds int) {
    this.Cache.Set(key, value, time.Duration(expireSeconds)*time.Second)
}


    // Sets the value if and only if there is no value associated with this key
func (this *GoCache) SetIfAbsent(key string, value []byte, expireSeconds int) bool {
    err := this.Cache.Add(key, value, time.Duration(expireSeconds)*time.Second)
    return err == nil
}
    
    // Deletes the value at the requested key
func (this *GoCache) Delete(key string) bool {
    this.Cache.Delete(key)
}

    // Gets the value at the requested key
func (this *GoCache) Get(key string) ([]byte, bool) {
    v, ok := this.Cache.Get(key)
    if !ok {
        return make([]byte,0), false
    }
    bt, ok := v.([]byte)
    return bt, ok
}

// Increment the key by val (val is allowed to be negative)
// in most implementation expireSeconds will be from the first increment, but users should not count on that.
// if no value is a present it should be added.  
// If a value is present which is not a number an error should be returned.
func (this *GoCache) Inc(key string, val int64, expireSeconds int) (int64, error) {
    this.lock.Lock()
    defer this.lock.Unlock()
    err := this.Cache.Increment(key, val)
    if err != nil {
        this.Cache.Set(key, val, time.Duration(expireSeconds)*time.Second)
        return val, nil
    }
    obj, ok := this.Cache.Get(key)
    if !ok {
        return int64(0), fmt.Errorf("Problem with increment") 
    }
    v, ok := obj.(int64)
    if !ok {
        return int64(0), fmt.Errorf("Problem with increment %s", obj) 
    }
    return v, nil
}
{'fraction_non_alphanumeric': 0.10986053339858087, 'fraction_numerical': 0.005382921458282359, 'mean_word_length': 3.141843971631206, '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': '651823', 'n_tokens_mistral': 1280, 'n_tokens_neox': 1231, 'n_words': 448}