Files
overleaf-cep/libraries/object-persistor/src/ProjectKey.js
Jakob Ackermann 95f0dac343 [clsi-cache] add sharded disk layout (#30763)
* [clsi-cache] remove old DiskCrawler

* [clsi-cache] use helpers for populating state during initial crawl

* [clsi-cache] use path helpers everywhere

* [clsi-cache] create project folder as part of the initial crawl

* [clsi-cache] add sharded disk layout

* [k8s] clsi-cache: switch clsi-cache-zone-b-shard-0 to new disk layout

* [clsi-cache] tweak logging context

* [monorepo] add bin/format_project_key util

* [k8s] clsi-cache: use a single nginx config file

GitOrigin-RevId: bb49146502cc6201eef210efae33355321efd77b
2026-01-15 14:19:28 +00:00

24 lines
638 B
JavaScript

const path = require('node:path')
//
// The advice in http://docs.aws.amazon.com/AmazonS3/latest/dev/
// request-rate-perf-considerations.html is to avoid sequential key prefixes,
// so we reverse the project ID part of the key as they suggest.
//
function format(projectId) {
const prefix = naiveReverse(pad(projectId))
return path.join(prefix.slice(0, 3), prefix.slice(3, 6), prefix.slice(6))
}
function pad(number) {
return (number || 0).toString().padStart(9, '0')
}
function naiveReverse(string) {
return string.split('').reverse().join('')
}
exports.format = format
exports.pad = pad
exports.naiveReverse = naiveReverse