3
0
Fork 0
mirror of https://github.com/Swatinem/rust-cache synced 2025-04-07 05:44:07 +00:00

add ability to version caches

This commit is contained in:
Arpad Borsos 2020-09-28 12:00:58 +02:00
parent cfcc373039
commit 1304a2ec8d
2 changed files with 11 additions and 7 deletions

View file

@ -45,18 +45,22 @@ export async function getCaches(): Promise<Caches> {
if (targetKey) { if (targetKey) {
targetKey = `${targetKey}-`; targetKey = `${targetKey}-`;
} }
const registryIndex = `v0-registry-index`;
const registryCache = `v0-registry-cache`;
const target = `v0-target-${targetKey}${rustKey}`;
return { return {
index: { index: {
name: "Registry Index", name: "Registry Index",
path: paths.index, path: paths.index,
key: "registry-index-XXX", key: `${registryIndex}-`,
restoreKeys: ["registry-index"], restoreKeys: [registryIndex],
}, },
cache: { cache: {
name: "Registry Cache", name: "Registry Cache",
path: paths.cache, path: paths.cache,
key: `registry-cache-${lockHash}`, key: `${registryCache}-${lockHash}`,
restoreKeys: ["registry-cache"], restoreKeys: [registryCache],
}, },
git: { git: {
name: "Git Dependencies", name: "Git Dependencies",
@ -66,8 +70,8 @@ export async function getCaches(): Promise<Caches> {
target: { target: {
name: "Target", name: "Target",
path: paths.target, path: paths.target,
key: `target-${targetKey}${rustKey}-${lockHash}`, key: `${target}-${lockHash}`,
restoreKeys: [`target-${targetKey}${rustKey}`], restoreKeys: [target],
}, },
}; };
} }

View file

@ -19,7 +19,7 @@ async function run() {
if (registryName) { if (registryName) {
// save the index based on its revision // save the index based on its revision
const indexRef = await getIndexRef(registryName); const indexRef = await getIndexRef(registryName);
caches.index.key = `registry-index-${indexRef}`; caches.index.key += indexRef;
await io.rmRF(path.join(paths.index, registryName, ".cache")); await io.rmRF(path.join(paths.index, registryName, ".cache"));
await pruneRegistryCache(registryName, packages); await pruneRegistryCache(registryName, packages);