This commit is contained in:
Tutur33
2023-11-24 22:35:41 +01:00
parent 3c0b507a93
commit 7644b2a0f7
45165 changed files with 4803356 additions and 3 deletions
+28
View File
@@ -0,0 +1,28 @@
import { LoaderTemplate, CacheManagerContract } from '../Contracts';
/**
* In memory cache manager to cache pre-compiled templates.
*/
export declare class CacheManager implements CacheManagerContract {
enabled: boolean;
private cacheStore;
constructor(enabled: boolean);
/**
* Returns a boolean to tell if a template has already been cached
* or not.
*/
has(absPath: string): boolean;
/**
* Returns the template from the cache. If caching is disabled,
* then it will return undefined.
*/
get(absPath: string): undefined | LoaderTemplate;
/**
* Set's the template path and the payload to the cache. If
* cache is disabled, then this function results in a noop.
*/
set(absPath: string, payload: LoaderTemplate): void;
/**
* Delete template from the compiled cache
*/
delete(absPath: string): void;
}
+57
View File
@@ -0,0 +1,57 @@
"use strict";
/*
* edge
*
* (c) Harminder Virk <virk@adonisjs.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.CacheManager = void 0;
/**
* In memory cache manager to cache pre-compiled templates.
*/
class CacheManager {
constructor(enabled) {
this.enabled = enabled;
this.cacheStore = new Map();
}
/**
* Returns a boolean to tell if a template has already been cached
* or not.
*/
has(absPath) {
return this.cacheStore.has(absPath);
}
/**
* Returns the template from the cache. If caching is disabled,
* then it will return undefined.
*/
get(absPath) {
if (!this.enabled) {
return;
}
return this.cacheStore.get(absPath);
}
/**
* Set's the template path and the payload to the cache. If
* cache is disabled, then this function results in a noop.
*/
set(absPath, payload) {
if (!this.enabled) {
return;
}
this.cacheStore.set(absPath, payload);
}
/**
* Delete template from the compiled cache
*/
delete(absPath) {
if (!this.enabled) {
return;
}
this.cacheStore.delete(absPath);
}
}
exports.CacheManager = CacheManager;