package settings

import (
	"context"
	"sync"
)

type MemoryStore struct {
	mu     sync.RWMutex
	values map[string]any
}

func NewMemoryStore() *MemoryStore {
	return &MemoryStore{values: map[string]any{}}
}

func (s *MemoryStore) Mode() string {
	return "memory-bootstrap"
}

func (s *MemoryStore) Get(ctx context.Context, key string) (any, bool, error) {
	_ = ctx
	s.mu.RLock()
	defer s.mu.RUnlock()
	value, ok := s.values[key]
	return value, ok, nil
}

func (s *MemoryStore) Set(ctx context.Context, key string, value any) error {
	_ = ctx
	s.mu.Lock()
	defer s.mu.Unlock()
	s.values[key] = value
	return nil
}
