Legendary Explorer Core Nightly
Core library for working with Mass Effect Trilogy / Legendary Edition files
Loading...
Searching...
No Matches
TieredPackageCache Class Reference

PackageCache implementation that allows looking for packages in parent caches. Parent caches will not open packages on cache miss. More...

Inheritance diagram for TieredPackageCache:

Public Member Functions

 TieredPackageCache (TieredPackageCache parent)
 Creates a tiered cache with the parent cache to look into if necessary More...
 
TieredPackageCache ChainNewCache (bool filenameOnlyMode=false, bool canPromoteInto=false)
 Chains a new child cache to this one and returns the child cache. More...
 
void PromotePackage (IMEPackage package)
 Moves a package into a higher tier. If a cache is shared, this will effectively cache this package for all children caches. This typically should only be used in a third tier cache; after global cache, chain a promotion tier, and then chain children off that. More...
 
override IMEPackage GetCachedPackage (string packageName, bool openIfNotInCache=true, Func< string, IMEPackage > openPackageMethod=null)
 Returns a cached package. Ensure this cache is synchronized if across threads or you may end up saving two different instances of files to the same location More...
 
override void InsertIntoCache (IMEPackage package)
 
override void CheckCacheFullness (bool gcOnRelease=false, bool largeGc=false)
 

Static Public Member Functions

static TieredPackageCache GetGlobalPackageCache (MEGame game, bool filenameOnlyMode=false, bool triggerOnFirstUse=true, string gameRootPath=null)
 Initializes a TieredPackageCache with the list of files that are globally safe to import from. This should be set as the root parent of tiered caches. More...
 

Public Attributes

TieredPackageCache ParentCache
 Cache to also look in for packages More...
 

Properties

bool CanBePromotedInto [get, set]
 If children caches can promote packages into this cache. Must be careful; too many promotions will result in high memory usage if the cache is long lived More...
 
bool FilenameOnlyMode [get, set]
 If this package cache should use filenames (rather than file paths) for cache lookups. More...
 
bool ReloadFileList [get, set]
 If next lookup in FilenameOnlyMode should refresh game files More...
 
int PackagePromotionThreshold = 5 [get, set]
 After child caches open the same package this many times, the package will be promoted into the parent cache. The parent cache must have 'CanBePromotedInto' set to true for this to do anything. More...
 
int ParentPromotionGuid [get, set]
 When checking parent for packages, if this does not match their current PromotionGuid, something was promoted into it, and we should drop any local packages that are now in the parent cache to reduce memory consumption More...
 
int PromotionGuid [get, set]
 Updated every time a package is promoted into this cache More...
 
int DropsUntilFullGC = 10 [get, set]
 When this amount of packages are dropped due to cache limit, a full GC will be performed More...
 

Detailed Description

PackageCache implementation that allows looking for packages in parent caches. Parent caches will not open packages on cache miss.

Constructor & Destructor Documentation

◆ TieredPackageCache()

TieredPackageCache.TieredPackageCache ( TieredPackageCache  parent)
inline

Creates a tiered cache with the parent cache to look into if necessary

Parameters
parentParent cache to look into

Member Function Documentation

◆ ChainNewCache()

TieredPackageCache TieredPackageCache.ChainNewCache ( bool  filenameOnlyMode = false,
bool  canPromoteInto = false 
)
inline

Chains a new child cache to this one and returns the child cache.

Parameters
filenameOnlyModeIf the cache only operates on filename and not filepath
canPromoteIntoIf the newly chained cache can be promoted into by its possible future children
Returns

◆ GetGlobalPackageCache()

static TieredPackageCache TieredPackageCache.GetGlobalPackageCache ( MEGame  game,
bool  filenameOnlyMode = false,
bool  triggerOnFirstUse = true,
string  gameRootPath = null 
)
inlinestatic

Initializes a TieredPackageCache with the list of files that are globally safe to import from. This should be set as the root parent of tiered caches.

Parameters
gameWhat game this cache will be for
filenameOnlyModeIf key lookups should be done on filename alone
gameRootPathUsed to override game path
Returns

◆ PromotePackage()

void TieredPackageCache.PromotePackage ( IMEPackage  package)
inline

Moves a package into a higher tier. If a cache is shared, this will effectively cache this package for all children caches. This typically should only be used in a third tier cache; after global cache, chain a promotion tier, and then chain children off that.

Parameters
package

◆ GetCachedPackage()

override IMEPackage TieredPackageCache.GetCachedPackage ( string  packageName,
bool  openIfNotInCache = true,
Func< string, IMEPackage >  openPackageMethod = null 
)
inline

Returns a cached package. Ensure this cache is synchronized if across threads or you may end up saving two different instances of files to the same location

Parameters
packageName
Returns

◆ InsertIntoCache()

override void TieredPackageCache.InsertIntoCache ( IMEPackage  package)
inline

◆ CheckCacheFullness()

override void TieredPackageCache.CheckCacheFullness ( bool  gcOnRelease = false,
bool  largeGc = false 
)
inline

Member Data Documentation

◆ ParentCache

TieredPackageCache TieredPackageCache.ParentCache

Cache to also look in for packages

Property Documentation

◆ CanBePromotedInto

bool TieredPackageCache.CanBePromotedInto
getset

If children caches can promote packages into this cache. Must be careful; too many promotions will result in high memory usage if the cache is long lived

◆ FilenameOnlyMode

bool TieredPackageCache.FilenameOnlyMode
getset

If this package cache should use filenames (rather than file paths) for cache lookups.

◆ ReloadFileList

bool TieredPackageCache.ReloadFileList
getset

If next lookup in FilenameOnlyMode should refresh game files

◆ PackagePromotionThreshold

int TieredPackageCache.PackagePromotionThreshold = 5
getset

After child caches open the same package this many times, the package will be promoted into the parent cache. The parent cache must have 'CanBePromotedInto' set to true for this to do anything.

◆ ParentPromotionGuid

int TieredPackageCache.ParentPromotionGuid
getset

When checking parent for packages, if this does not match their current PromotionGuid, something was promoted into it, and we should drop any local packages that are now in the parent cache to reduce memory consumption

◆ PromotionGuid

int TieredPackageCache.PromotionGuid
getset

Updated every time a package is promoted into this cache

◆ DropsUntilFullGC

int TieredPackageCache.DropsUntilFullGC = 10
getset

When this amount of packages are dropped due to cache limit, a full GC will be performed


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