package models

import "sync"

type Cache struct {
	Data map[string][]byte
	Mu   sync.RWMutex
}

func initCache() *Cache {
	return &Cache{Data: make(map[string][]byte)}
}

func (c *Cache) Get(key string) ([]byte, bool) {
	c.Mu.RLock()
	pageData, ok := c.Data[key]
	c.Mu.RUnlock()
	return pageData, ok
}

func (c *Cache) Set(key string, data []byte) {
	c.Mu.Lock()
	c.Data[key] = data
	c.Mu.Unlock()
}
