mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-25 18:20:09 +02:00
* [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
24 lines
638 B
JavaScript
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
|