<commit_before>// Package list provides a list of Image Cache
package list

import (
	"github.com/pierrre/imageserver"
)

// ListCache represents a list of Image Cache
type ListCache []imageserver.Cache

// Get gets an Image from caches in sequential order
//
// If an Image is found, previous caches are filled
func (cache ListCache) Get(key string, parameters imageserver.Parameters) (*imageserver.Image, error) {
	for i, c := range cache {
		image, err := c.Get(key, parameters)

		if err == nil {
			if i > 0 {
				cache.setCaches(key, image, parameters, i)
			}
			return image, nil
		}
	}

	return nil, imageserver.NewCacheMissError(key, cache, nil)
}

func (cache ListCache) setCaches(key string, image *imageserver.Image, parameters imageserver.Parameters, indexLimit int) {
	for i := 0; i < indexLimit; i++ {
		go func(i int) {
			cache[i].Set(key, image, parameters)
		}(i)
	}
}

// Set sets the image to all caches
func (cache ListCache) Set(key string, image *imageserver.Image, parameters imageserver.Parameters) error {
	for _, c := range cache {
		go func(c imageserver.Cache) {
			c.Set(key, image, parameters)
		}(c)
	}
	return nil
}<commit_msg>remove async feature from ListCache<commit_after>// Package list provides a list of Image Cache
package list

import (
	"github.com/pierrre/imageserver"
)

// ListCache represents a list of Image Cache
type ListCache []imageserver.Cache

// Get gets an Image from caches in sequential order
//
// If an Image is found, previous caches are filled
func (cache ListCache) Get(key string, parameters imageserver.Parameters) (*imageserver.Image, error) {
	for i, c := range cache {
		image, err := c.Get(key, parameters)
		if err == nil {
			if i > 0 {
				err = cache.set(key, image, parameters, i)
				if err != nil {
					return nil, err
				}
			}
			return image, nil
		}
	}

	return nil, imageserver.NewCacheMissError(key, cache, nil)
}

func (cache ListCache) set(key string, image *imageserver.Image, parameters imageserver.Parameters, indexLimit int) error {
	for i := 0; i < indexLimit; i++ {
		err := cache[i].Set(key, image, parameters)
		if err != nil {
			return err
		}
	}
	return nil
}

// Set sets the image to all caches
func (cache ListCache) Set(key string, image *imageserver.Image, parameters imageserver.Parameters) error {
	return cache.set(key, image, parameters, len(cache))
}
{'fraction_non_alphanumeric': 0.11148791860958034, 'fraction_numerical': 0.001695633743111488, 'mean_word_length': 3.7580645161290325, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7416546', 'n_tokens_mistral': 816, 'n_tokens_neox': 739, 'n_words': 270}