mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-23 07:57:51 -05:00
clear all server caches after leaving modslayer
This commit is contained in:
parent
ece3fd22d8
commit
98dc9f51cd
3 changed files with 15 additions and 4 deletions
|
@ -75,6 +75,8 @@ namespace server {
|
|||
std::optional<std::string> developer;
|
||||
size_t page = 0;
|
||||
size_t pageSize = 10;
|
||||
|
||||
bool operator==(ModsQuery const& other) const = default;
|
||||
};
|
||||
|
||||
struct ServerError {
|
||||
|
@ -199,7 +201,7 @@ namespace server {
|
|||
Cache m_cache;
|
||||
|
||||
public:
|
||||
static ServerResultCache<F>& shared() {
|
||||
static ServerResultCache& shared() {
|
||||
static auto inst = ServerResultCache();
|
||||
static auto _ = listenForSettingChanges<int64_t>("server-cache-size-limit", +[](int64_t size) {
|
||||
ServerResultCache::shared().setSizeLimit(size);
|
||||
|
@ -225,4 +227,11 @@ namespace server {
|
|||
m_cache.limit(size);
|
||||
}
|
||||
};
|
||||
|
||||
// Clear all shared server endpoint caches
|
||||
static void clearServerCaches() {
|
||||
ServerResultCache<&getMods>::shared().invalidateAll();
|
||||
ServerResultCache<&getMod>::shared().invalidateAll();
|
||||
ServerResultCache<&getModLogo>::shared().invalidateAll();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ static auto loadInstalledModsPage(server::ModsQuery&& query) {
|
|||
}
|
||||
|
||||
static auto loadServerModsPage(server::ModsQuery&& query) {
|
||||
return server::getMods(query)
|
||||
return server::ServerResultCache<&server::getMods>::shared().get(query)
|
||||
.then<ModListSource::ProvidedMods>([](server::ServerModsList list) {
|
||||
auto content = ModListSource::ProvidedMods();
|
||||
for (auto&& mod : std::move(list.mods)) {
|
||||
|
|
|
@ -264,7 +264,9 @@ void ModsLayer::onRefreshList(CCObject*) {
|
|||
|
||||
void ModsLayer::onBack(CCObject*) {
|
||||
CCDirector::get()->replaceScene(CCTransitionFade::create(.5f, MenuLayer::scene(false)));
|
||||
server::ServerResultCache<&server::getModLogo>::shared().invalidateAll();
|
||||
|
||||
// To avoid memory overloading, clear caches after leaving the layer
|
||||
server::clearServerCaches();
|
||||
}
|
||||
|
||||
void ModsLayer::onGoToPage(CCObject*) {
|
||||
|
|
Loading…
Reference in a new issue