func (s *MemoryStorage) Save(post *model.Post) error {
	s.posts.Store(post.Path, post)
	s.postsCount++
	for i := range post.Tags {
		tag := &model.Tag{Tag: post.Tags[i], Paths: []string{post.Path}}
		tagSlice := postSlice{post}
		loadedTag, ok := s.tags.LoadOrStore(strings.ToLower(post.Tags[i]), tag)
		loadedTagSlice, ok := s.tagsList.LoadOrStore(strings.ToLower(post.Tags[i]), tagSlice)
		if ok {
			loadedTag.(*model.Tag).Paths = append(loadedTag.(*model.Tag).Paths, post.Path)
			loadedTagSlice = append(loadedTagSlice.(postSlice), post)
			s.tags.Store(strings.ToLower(post.Tags[i]), loadedTag)
			s.tagsList.Store(strings.ToLower(post.Tags[i]), loadedTagSlice)
		}
	}
	return nil
}
Save persists new post in the storage
package storage
import (
	"math"
	"sort"
	"strings"
	"sync"
	"github.com/vgarvardt/rklotz/pkg/model"
)
type postSlice []*model.Post
func (p postSlice) Len() int { return len(p) }
func (p postSlice) Less(i, j int) bool { return p[i].PublishedAt.Before(p[j].PublishedAt) }
func (p postSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
type MemoryStorage struct {
	posts *sync.Map
	tags  *sync.Map
	postsList postSlice
	tagsList  *sync.Map
	postsCount   int
	postsPerPage int
}
func NewMemoryStorage(postsPerPage int) (*MemoryStorage, error) {
	instance := &MemoryStorage{
		posts:        new(sync.Map),
		tags:         new(sync.Map),
		tagsList:     new(sync.Map),
		postsPerPage: postsPerPage,
	}
	return instance, nil
}