You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: cache_memory.go
    path of file: ./repos/benthos/internal/impl/pure
    
    the code of the file until where you have to start completion: package pure

import (
	"context"
	"sync"
	"time"

	"github.com/OneOfOne/xxhash"

	"github.com/benthosdev/benthos/v4/public/service"
)

func memCacheConfig() *service.ConfigSpec {
	spec := service.NewConfigSpec().
		Stable().
		Summary(`Stores key/value pairs in a map held in memory. This cache is therefore reset every time the service restarts. Each ite
    
func newMemCache(ttl, compInterval time.Duration, nShards int, initValues map[string]string) *memoryCache {
	m := &memoryCache{
		defaultTTL: ttl,
	}

	if nShards <= 1 {
		m.shards = []*shard{
			{
				items:          map[string]item{},
				compInterval:   compInterval,
				lastCompaction: time.Now(),
			},
		}
	} else {
		for i := 0; i < nShards; i++ {
			m.shards = append(m.shards, &shard{
				items:          map[string]item{},
				compInterval:   compInterval,
				lastCompaction: time.Now(),
			})
		}
	}

	for k, v := range initValues {
		m.getShard(k).items[k] = item{
			value:   []byte(v),
			expires: time.Time{},
		}
	}

	return m
}