Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,15 @@ If `filter` is a boolean, it is interpreted as `excludeShared` for backward comp
`ownsPackage(16018, true)` is the same as `ownsPackage(16018, {excludeShared: true})`.
This usage is deprecated and will be removed in a future release.

### clearPicsCache()

**v4.xx.x or later is required to use this method**

Clears the content of the `picsCache` object and removes any associated jobs to free memory.
Make sure to disable [`changelistUpdateInterval`](#changelistUpdateInterval) if the cache should not get repopulated.

`enablePicsCache` must be `true` to use this method. Otherwise, an `Error` will be thrown.

### getStoreTagNames(language, tagIDs, callback)
- `language` - The language you want tag names in, e.g. "english" or "spanish"
- `tagIDs` - An array of one or more tag IDs
Expand Down
1 change: 1 addition & 0 deletions components/03-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ class SteamUserMessages extends SteamUserConnection {
if (callback) {
jobIdSource = ++this._currentJobID;
this._jobs[jobIdSource] = callback;
this._jobs[jobIdSource].type = emsg; // Save type of this job to be able to filter the object later on

// Clean up old job callbacks after 2 minutes
this._jobCleanupTimers.push(setTimeout(() => delete this._jobs[jobIdSource], 1000 * 60 * 2));
Expand Down
28 changes: 28 additions & 0 deletions components/apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,34 @@ class SteamUserApps extends SteamUserAppAuth {
}
}

/**
* Clears the current picsCache content.
* Make sure to disable 'changelistUpdateInterval' if the cache should not get repopulated.
*/
clearPicsCache() {
if (!this.options.enablePicsCache) {
throw new Error("PICS cache is not enabled.");
}

// Reset cache back to default
this.picsCache = {
changenumber: 0,
apps: {},
packages: {}
};

// Filter jobs object for left over references to the old picsCache content so it will be garbage collected instantly
Object.keys(this._jobs).forEach((e) => {
let k = this._jobs[e];

if (k.type && [ EMsg.ClientPICSChangesSinceRequest, EMsg.ClientPICSProductInfoRequest, EMsg.ClientPICSAccessTokenRequest ].includes(k.type)) {
delete this._jobs[e];
clearTimeout(this._jobCleanupTimers[e]);
delete this._jobCleanupTimers[e];
}
});
}

/**
* @protected
*/
Expand Down