2024-05-08 00:52:47 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "federated.computer/wp-sync-slowtwitch/services/wordpress"
|
|
|
|
|
|
|
|
type AppCache struct {
|
|
|
|
UsersCache map[string]wordpress.UserData
|
2024-05-08 01:23:21 +00:00
|
|
|
TagCache map[string]wordpress.TagData
|
2024-05-08 00:52:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (appCache *AppCache) GetUser(username string) (wordpress.UserData, bool) {
|
|
|
|
user, ok := appCache.UsersCache[username]
|
|
|
|
return user, ok
|
|
|
|
}
|
|
|
|
|
|
|
|
func (appCache *AppCache) SetUser(user wordpress.UserData) {
|
|
|
|
if appCache.UsersCache == nil {
|
|
|
|
appCache.UsersCache = make(map[string]wordpress.UserData)
|
|
|
|
}
|
|
|
|
appCache.UsersCache[user.Name] = user
|
|
|
|
}
|
2024-05-08 01:23:21 +00:00
|
|
|
|
|
|
|
func (appCache *AppCache) GetTag(tagName string) (wordpress.TagData, bool) {
|
|
|
|
tag, ok := appCache.TagCache[tagName]
|
|
|
|
return tag, ok
|
|
|
|
}
|
|
|
|
|
|
|
|
func (appCache *AppCache) SetTag(tag wordpress.TagData) {
|
|
|
|
if appCache.TagCache == nil {
|
|
|
|
appCache.TagCache = make(map[string]wordpress.TagData)
|
|
|
|
}
|
|
|
|
appCache.TagCache[tag.Name] = tag
|
|
|
|
}
|