Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Revert "removed caching while getting groups"#359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Changes fromall 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
32 changes: 13 additions & 19 deletionssrc/services/groups.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -320,32 +320,26 @@ class GroupService {
* @return {Promise} Resolves to ID array.
*/
async getGroupTreeIds(rootGroupId, maxage = 5 * 60 * 1000) {
//TODO: Once the fix is validated and working, remove all commented code related to caching
/**
* Removing the caching mechanism,
* as the group created on the day will only be pickedup on the next day
* and stored in the cache
*/
// const now = Date.now();
// const cache = this.private.cache.groupTreeIds;
const now = Date.now();
const cache = this.private.cache.groupTreeIds;

/* Clean-up: removes stale records from the cache. */
//const CLEAN_UP_INTERVAL = 24 * 60 * 60 * 1000; // 1 day in ms.
//if (now - cache.lastCleanUp > CLEAN_UP_INTERVAL) {
// _.forOwn(cache, ({ timestamp }, key) => {
// if (now - timestamp > CLEAN_UP_INTERVAL) delete cache[key];
// });
// cache.lastCleanUp = now;
//}
const CLEAN_UP_INTERVAL = 24 * 60 * 60 * 1000; // 1 day in ms.
if (now - cache.lastCleanUp > CLEAN_UP_INTERVAL) {
_.forOwn(cache, ({ timestamp }, key) => {
if (now - timestamp > CLEAN_UP_INTERVAL) delete cache[key];
});
cache.lastCleanUp = now;
}

/* If result is found in cache, and is fresh enough, return it. */
//const cached = cache[rootGroupId];
//if (cached && now - cached.timestamp < maxage) return _.clone(cached.data);
const cached = cache[rootGroupId];
if (cached && now - cached.timestamp < maxage) return _.clone(cached.data);

/* Otherwise, fetch result from the API, write it to the cache, and
* finally return that. */
const res = reduceGroupIds(await this.getGroup(rootGroupId));
//cache[rootGroupId] = { data: res, timestamp: now };
cache[rootGroupId] = { data: res, timestamp: now };
return _.clone(res);
}

Expand DownExpand Up@@ -415,4 +409,4 @@ export function getService(tokenV3) {
return lastInstance;
}

export default undefined;
export default undefined;

[8]ページ先頭

©2009-2025 Movatter.jp