Skip to content

Commit

Permalink
feat: built-in cache allow toggling on/off
Browse files Browse the repository at this point in the history
  • Loading branch information
etienne-85 committed Aug 14, 2024
1 parent 3506442 commit b66c6be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/data/CacheContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class CacheContainer extends PatchContainer {
// eslint-disable-next-line no-use-before-define
static singleton: CacheContainer
pendingRefresh = false
builtInCache = false // specify whether cache is managed internally or separately
static cachePowRadius = 2
static cacheSize = BlocksPatch.patchSize * 5
// static worldApi = new WorldApi()
Expand Down Expand Up @@ -45,7 +46,7 @@ export class CacheContainer extends PatchContainer {
* @param dryRun
* @returns true if cache was update, false otherwise
*/
async refresh(bbox: Box3, dryRun = false) {
async refresh(bbox: Box3) {
let changesDiff
if (!this.pendingRefresh) {
const emptyContainer = new PatchContainer()
Expand All @@ -61,7 +62,7 @@ export class CacheContainer extends PatchContainer {
super.init(bbox)
// restore remaining patches backup
this.populateFromExisting(backup)
!dryRun && (await this.populate(this.missingPatchKeys))
this.builtInCache && (await this.populate(this.missingPatchKeys))
}
}
// return patch keys changes
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export { BoardContainer } from './data/BoardContainer'
export { Biome, BlockType } from './procgen/Biome'
export { EntitiesMap, RepeatableEntitiesMap } from './procgen/EntitiesMap'
export { EntityType } from './common/types'
export { CacheContainer } from './data/CacheContainer'
export { CacheContainer as WorldCacheContainer } from './data/CacheContainer'
export { WorldComputeApi } from './compute/WorldComputeApi'
export * as WorldCompute from './compute/world-compute'
export * as WorldUtils from './common/utils'
Expand Down

0 comments on commit b66c6be

Please sign in to comment.