only log a message if there are event cache entries, and formatting
This commit is contained in:
parent
93e02e852a
commit
758fea4195
2 changed files with 17 additions and 15 deletions
|
|
@ -16,7 +16,6 @@ export namespace EventDataCache {
|
||||||
|
|
||||||
if (force == true || isAnythingUndefined) {
|
if (force == true || isAnythingUndefined) {
|
||||||
log("Initialising global.cache")
|
log("Initialising global.cache")
|
||||||
// global.cache = new Map<CacheKey<FactorioEventUpdateType>, CacheEntry<FactorioEventUpdateType>>()
|
|
||||||
global.cache = new LuaTable<string, CacheEntry<FactorioEventUpdateType>>()
|
global.cache = new LuaTable<string, CacheEntry<FactorioEventUpdateType>>()
|
||||||
|
|
||||||
log("Initialising global.DEFAULT_CACHE_DURATION_TICKS")
|
log("Initialising global.DEFAULT_CACHE_DURATION_TICKS")
|
||||||
|
|
@ -95,7 +94,9 @@ export namespace EventDataCache {
|
||||||
global.cache.delete(key)
|
global.cache.delete(key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log(`cache expired items count: ${countExpired}, total: ${countTotal}`)
|
if (countExpired + countTotal > 0) {
|
||||||
|
log(`cache expired items count: ${countExpired}, total: ${countTotal}`)
|
||||||
|
}
|
||||||
return expiredData
|
return expiredData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -130,7 +131,7 @@ export namespace EventDataCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// /** Map a {@link FactorioEventUpdateType} to a {@link FactorioEventUpdate} DTO */
|
/** Map a {@link FactorioEventUpdateType} to a {@link FactorioEventUpdate} DTO */
|
||||||
type ConvertToUpdate<TYPE extends FactorioEventUpdateType> =
|
type ConvertToUpdate<TYPE extends FactorioEventUpdateType> =
|
||||||
TYPE extends "PLAYER" ? PlayerUpdate :
|
TYPE extends "PLAYER" ? PlayerUpdate :
|
||||||
TYPE extends "MAP_CHUNK" ? MapChunkUpdate :
|
TYPE extends "MAP_CHUNK" ? MapChunkUpdate :
|
||||||
|
|
@ -138,6 +139,7 @@ export namespace EventDataCache {
|
||||||
never
|
never
|
||||||
|
|
||||||
|
|
||||||
|
/** Map a {@link FactorioEventUpdateType} to a {@link FactorioEventUpdateKey} */
|
||||||
type ConvertToUpdateKey<TYPE extends FactorioEventUpdateType> =
|
type ConvertToUpdateKey<TYPE extends FactorioEventUpdateType> =
|
||||||
TYPE extends "PLAYER" ? PlayerUpdateKey :
|
TYPE extends "PLAYER" ? PlayerUpdateKey :
|
||||||
TYPE extends "MAP_CHUNK" ? MapChunkUpdateKey :
|
TYPE extends "MAP_CHUNK" ? MapChunkUpdateKey :
|
||||||
|
|
@ -151,7 +153,7 @@ export namespace EventDataCache {
|
||||||
& Omit<ConvertToUpdateKey<TYPE>, "updateType">
|
& Omit<ConvertToUpdateKey<TYPE>, "updateType">
|
||||||
|
|
||||||
|
|
||||||
/** Make nullable-fields optional, and `updateType` specific */
|
/** Make `updateType` specific */
|
||||||
export type CacheData<TYPE extends FactorioEventUpdateType> =
|
export type CacheData<TYPE extends FactorioEventUpdateType> =
|
||||||
CacheTyped<TYPE>
|
CacheTyped<TYPE>
|
||||||
& Omit<ConvertToUpdate<TYPE>, "updateType">
|
& Omit<ConvertToUpdate<TYPE>, "updateType">
|
||||||
|
|
@ -205,11 +207,11 @@ export namespace EventDataCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function isKeyInstanceOf<TYPE extends FactorioEventUpdateType>(
|
// function isKeyInstanceOf<TYPE extends FactorioEventUpdateType>(
|
||||||
key: CacheKey<any> | undefined,
|
// key: CacheKey<any> | undefined,
|
||||||
updateType: TYPE,
|
// updateType: TYPE,
|
||||||
): key is CacheKey<TYPE> {
|
// ): key is CacheKey<TYPE> {
|
||||||
return key != undefined && key.updateType == updateType
|
// return key != undefined && key.updateType == updateType
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ class FactorioEventUpdatePacket(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
|
|
||||||
sealed interface FactorioEventUpdateKey {
|
sealed interface FactorioEventUpdateKey {
|
||||||
|
|
@ -83,7 +83,7 @@ sealed class FactorioEventUpdate : FactorioEventUpdateKey {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
|
|
||||||
sealed interface PlayerUpdateKey : FactorioEventUpdateKey {
|
sealed interface PlayerUpdateKey : FactorioEventUpdateKey {
|
||||||
|
|
@ -128,7 +128,7 @@ data class PlayerUpdate(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
|
|
||||||
sealed interface EntityUpdateKey : EntityIdentifiers, FactorioEventUpdateKey {
|
sealed interface EntityUpdateKey : EntityIdentifiers, FactorioEventUpdateKey {
|
||||||
|
|
@ -163,7 +163,7 @@ data class EntityUpdate(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
|
|
||||||
sealed interface MapChunkUpdateKey : FactorioEventUpdateKey {
|
sealed interface MapChunkUpdateKey : FactorioEventUpdateKey {
|
||||||
|
|
@ -195,4 +195,4 @@ data class MapChunkUpdate(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue