game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
ProtonCache Class Reference

Thread-safe cache for Proton version scanning results. More...

#include <proton_cache.h>

Static Public Member Functions

static int getCacheAge ()
 Get cache age in seconds.
static std::vector< std::string > getSortedVersionNames ()
 Get sorted Proton version names only.
static std::vector< std::pair< std::string, std::filesystem::path > > getVersions ()
 Get cached Proton versions.
static void invalidate ()
 Invalidate the cache.
static bool isValid ()
 Check if cache is currently valid.

Detailed Description

Thread-safe cache for Proton version scanning results.

Caches the results of expensive Proton version scans to avoid repeated filesystem traversal. Cache automatically invalidates after a configurable time period or can be manually invalidated.

Thread Safety

All methods are thread-safe via mutex protection.

Cache Invalidation

Cache invalidates automatically after PROTON_CACHE_VALIDITY_SEC seconds. Can also be manually invalidated via invalidate().

Usage Example

// Get cached Proton versions (scans filesystem only if cache expired)
auto versions = ProtonCache::getVersions();
// Manual invalidation (e.g., after installing new Proton)
static std::vector< std::pair< std::string, std::filesystem::path > > getVersions()
Get cached Proton versions.
static void invalidate()
Invalidate the cache.

Definition at line 47 of file proton_cache.h.

Member Function Documentation

◆ getCacheAge()

int ProtonCache::getCacheAge ( )
static

Get cache age in seconds.

Returns
Number of seconds since cache was last updated

Definition at line 102 of file proton_cache.cpp.

◆ getSortedVersionNames()

std::vector< std::string > ProtonCache::getSortedVersionNames ( )
static

Get sorted Proton version names only.

Returns
Vector of Proton version names sorted by priority

Convenience method that returns just the names in sorted order:

  1. CachyOS versions first
  2. Experimental versions next
  3. Others by version number

Definition at line 42 of file proton_cache.cpp.

References getVersions().

◆ getVersions()

std::vector< std::pair< std::string, std::filesystem::path > > ProtonCache::getVersions ( )
static

Get cached Proton versions.

Returns
Vector of (name, path) pairs for all Proton versions

Returns cached results if cache is valid, otherwise rescans filesystem and updates cache. Thread-safe.

Definition at line 29 of file proton_cache.cpp.

Referenced by getSortedVersionNames().

◆ invalidate()

void ProtonCache::invalidate ( )
static

Invalidate the cache.

Forces a rescan on next getVersions() call. Use this when:

  • New Proton version installed
  • Proton version removed
  • Steam library paths changed

Definition at line 88 of file proton_cache.cpp.

References Logger::info().

Referenced by RunnerDownloadService::downloadRunner(), and RunnerDownloadService::uninstallRunner().

◆ isValid()

bool ProtonCache::isValid ( )
static

Check if cache is currently valid.

Returns
True if cache exists and hasn't expired

Definition at line 96 of file proton_cache.cpp.


The documentation for this class was generated from the following files: