sync
This commit is contained in:
@@ -487,9 +487,11 @@ class PearcordPlatform extends EventEmitter {
|
||||
this._reactionListCacheKey = ''
|
||||
this._reactionListCache = null
|
||||
this._reactionListCacheGen = 0
|
||||
this._reactionListPending = null
|
||||
this._pinListCacheKey = ''
|
||||
this._pinListCache = null
|
||||
this._pinListCacheGen = 0
|
||||
this._pinListPending = null
|
||||
this._lastReplicationCompact = null
|
||||
this._memberPageBurstTimestamps = []
|
||||
this._guildMeshBoundedByGuild = new Map()
|
||||
@@ -755,12 +757,14 @@ class PearcordPlatform extends EventEmitter {
|
||||
this._reactionListCacheGen = (this._reactionListCacheGen || 0) + 1
|
||||
this._reactionListCacheKey = ''
|
||||
this._reactionListCache = null
|
||||
this._reactionListPending = null
|
||||
}
|
||||
|
||||
_invalidatePinListCache () {
|
||||
this._pinListCacheGen = (this._pinListCacheGen || 0) + 1
|
||||
this._pinListCacheKey = ''
|
||||
this._pinListCache = null
|
||||
this._pinListPending = null
|
||||
}
|
||||
|
||||
_logMeshChurn (action, extra = {}) {
|
||||
@@ -20063,37 +20067,78 @@ class PearcordPlatform extends EventEmitter {
|
||||
this._reactionListCache?.reactions
|
||||
) {
|
||||
reactions = this._reactionListCache.reactions
|
||||
} else {
|
||||
const listSpan = this.log.time('reaction.list', {
|
||||
const cachedRows = Array.isArray(this._reactionListCache.rows) ? this._reactionListCache.rows : []
|
||||
this.log.debug('reaction.list cache hit', {
|
||||
spanKind: 'reaction.list',
|
||||
channelId: this.activeChannelId,
|
||||
guildId: reactionGuildId,
|
||||
rowCount: cachedRows.length,
|
||||
messageCount: Object.keys(reactions).length,
|
||||
activeChannelId: this.activeChannelId,
|
||||
guildCount: (this.guilds || []).length,
|
||||
cached: true,
|
||||
light
|
||||
})
|
||||
try {
|
||||
const rows = await this.messages.listReactions()
|
||||
reactions = this._groupReactions(rows)
|
||||
this._reactionListCacheKey = cacheKey
|
||||
this._reactionListCache = { rows, reactions }
|
||||
listSpan.end({
|
||||
} else {
|
||||
const pending = this._reactionListPending
|
||||
if (pending && pending.cacheKey === cacheKey) {
|
||||
const rowCount = Array.isArray(pending.rows) ? pending.rows.length : null
|
||||
this.log.debug('reaction.list pending cache hit', {
|
||||
spanKind: 'reaction.list',
|
||||
channelId: this.activeChannelId,
|
||||
guildId: reactionGuildId,
|
||||
rowCount: rows.length,
|
||||
messageCount: Object.keys(reactions).length,
|
||||
rowCount,
|
||||
activeChannelId: this.activeChannelId,
|
||||
guildCount: (this.guilds || []).length,
|
||||
cached: false,
|
||||
cached: true,
|
||||
pending: true,
|
||||
light
|
||||
})
|
||||
} catch (err) {
|
||||
this.log.error('reaction.list error', {
|
||||
try {
|
||||
const out = await pending.promise
|
||||
reactions = out.reactions || {}
|
||||
} catch {
|
||||
reactions = {}
|
||||
}
|
||||
} else {
|
||||
const listSpan = this.log.time('reaction.list', {
|
||||
spanKind: 'reaction.list',
|
||||
channelId: this.activeChannelId,
|
||||
guildId: reactionGuildId,
|
||||
error: err?.message || String(err)
|
||||
light
|
||||
})
|
||||
listSpan.fail(err)
|
||||
reactions = {}
|
||||
const loader = (async () => {
|
||||
const rows = await this.messages.listReactions()
|
||||
return { rows, reactions: this._groupReactions(rows) }
|
||||
})()
|
||||
this._reactionListPending = { cacheKey, promise: loader, rows: null }
|
||||
try {
|
||||
const out = await loader
|
||||
reactions = out.reactions
|
||||
this._reactionListCacheKey = cacheKey
|
||||
this._reactionListCache = { rows: out.rows, reactions: out.reactions }
|
||||
this._reactionListPending = null
|
||||
listSpan.end({
|
||||
spanKind: 'reaction.list',
|
||||
channelId: this.activeChannelId,
|
||||
guildId: reactionGuildId,
|
||||
rowCount: out.rows.length,
|
||||
messageCount: Object.keys(reactions).length,
|
||||
activeChannelId: this.activeChannelId,
|
||||
guildCount: (this.guilds || []).length,
|
||||
cached: false,
|
||||
light
|
||||
})
|
||||
} catch (err) {
|
||||
this.log.error('reaction.list error', {
|
||||
channelId: this.activeChannelId,
|
||||
guildId: reactionGuildId,
|
||||
error: err?.message || String(err)
|
||||
})
|
||||
this._reactionListPending = null
|
||||
listSpan.fail(err)
|
||||
reactions = {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20134,10 +20179,46 @@ class PearcordPlatform extends EventEmitter {
|
||||
const pinCacheKey = `${pinGuildId}:${this.activeChannelId || ''}:${this._pinListCacheGen || 0}`
|
||||
if (this._pinListCacheKey === pinCacheKey && Array.isArray(this._pinListCache?.pins)) {
|
||||
pins = this._pinListCache.pins
|
||||
this.log.debug('pin.list cache hit', {
|
||||
spanKind: 'search.pins',
|
||||
channelId: this.activeChannelId,
|
||||
guildId: pinGuildId,
|
||||
guildCount: (this.guilds || []).length,
|
||||
pinCount: pins.length,
|
||||
activeChannelId: this.activeChannelId,
|
||||
cached: true
|
||||
})
|
||||
} else {
|
||||
pins = await this._channelPins(this.activeChannelId, pinGuildId)
|
||||
this._pinListCacheKey = pinCacheKey
|
||||
this._pinListCache = { pins }
|
||||
const pending = this._pinListPending
|
||||
if (pending && pending.cacheKey === pinCacheKey) {
|
||||
this.log.debug('pin.list pending cache hit', {
|
||||
spanKind: 'search.pins',
|
||||
channelId: this.activeChannelId,
|
||||
guildId: pinGuildId,
|
||||
guildCount: (this.guilds || []).length,
|
||||
pinCount: Array.isArray(pending.pins) ? pending.pins.length : null,
|
||||
activeChannelId: this.activeChannelId,
|
||||
cached: true,
|
||||
pending: true
|
||||
})
|
||||
try {
|
||||
pins = await pending.promise
|
||||
} catch {
|
||||
pins = []
|
||||
}
|
||||
} else {
|
||||
const loader = this._channelPins(this.activeChannelId, pinGuildId)
|
||||
this._pinListPending = { cacheKey: pinCacheKey, promise: loader, pins: null }
|
||||
try {
|
||||
pins = await loader
|
||||
this._pinListPending = null
|
||||
this._pinListCacheKey = pinCacheKey
|
||||
this._pinListCache = { pins }
|
||||
} catch {
|
||||
this._pinListPending = null
|
||||
pins = []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const channelSettings = {}
|
||||
|
||||
Reference in New Issue
Block a user