Skip to content

Commit

Permalink
fix(core): object caching uses proper key
Browse files Browse the repository at this point in the history
  • Loading branch information
slvnperron committed Jun 16, 2019
1 parent 4732f3f commit ef3c460
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/bp/core/misc/utils.ts
Expand Up @@ -61,7 +61,9 @@ export const forceForwardSlashes = path => path.replace(/\\/g, '/')
export const getCacheKeyInMinutes = (minutes: number = 1) => Math.round(new Date().getTime() / 1000 / 60 / minutes)

export const asBytes = (size: string) => {
const matches = (size || '')
size = typeof size === 'string' ? size : '0'

const matches = size
.replace(',', '.')
.toLowerCase()
.match(/(\d+\.?\d{0,})\s{0,}(mb|gb|pt|kb|b)?/i)
Expand Down
2 changes: 0 additions & 2 deletions src/bp/core/services/ghost/memory-cache.ts
Expand Up @@ -19,8 +19,6 @@ export default class MemoryObjectCache implements ObjectCache {
length: (n, key) => {
if (key.startsWith('buffer::')) {
return n.length
} else if (key.startsWith('string::')) {
return n.length * 2 // each char is 2 bytes in ECMAScript
}

return 500 // Assuming 500 bytes per objects, this is kind of random
Expand Down
2 changes: 1 addition & 1 deletion src/bp/core/services/ghost/service.ts
Expand Up @@ -155,7 +155,7 @@ export class ScopedGhostService {
return forceForwardSlashes(path.join(this._normalizeFolderName(rootFolder), file))
}

objectCacheKey = str => `string::${str}`
objectCacheKey = str => `object::${str}`
bufferCacheKey = str => `buffer::${str}`

private async _invalidateFile(fileName: string) {
Expand Down

0 comments on commit ef3c460

Please sign in to comment.