From b575f5b72d59bc8d84fb7644859ff58a9af2c4d8 Mon Sep 17 00:00:00 2001 From: Pieter Heyvaert Date: Wed, 9 Mar 2022 14:52:49 +0100 Subject: [PATCH] add docs --- src/any-to-rdf-converter.ts | 16 ++++++++++++++++ test/test.ts | 1 - 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/any-to-rdf-converter.ts b/src/any-to-rdf-converter.ts index 16acc7d..094b68c 100644 --- a/src/any-to-rdf-converter.ts +++ b/src/any-to-rdf-converter.ts @@ -105,6 +105,10 @@ export class AnyToRdfConverter extends BaseTypedRepresentationConverter { ); } + /** + * Get RDF from the cache. + * @param data - The data to use to determine the hash for the caching. + */ _getRDFFromCache(data: string) { if (this.cache) { const hash: string = crypto.createHash('md5').update(data).digest("hex"); @@ -125,6 +129,11 @@ export class AnyToRdfConverter extends BaseTypedRepresentationConverter { return null; } + /** + * Store RDF in the cache. + * @param data - The data that is used to determine to hash for caching. + * @param rdf - The RDF that is stored. + */ _setRDFinCache(data: string, rdf: string) { if (this.cache) { const hash: string = crypto.createHash('md5').update(data).digest("hex"); @@ -132,6 +141,10 @@ export class AnyToRdfConverter extends BaseTypedRepresentationConverter { } } + /** + * This method removes RDF from the cache that hasn't been used in a while. + * This is based on this.cacheRetention. + */ _cleanUpCache() { const now = (new Date()).getTime(); // @ts-ignore @@ -152,6 +165,9 @@ export class AnyToRdfConverter extends BaseTypedRepresentationConverter { }); } + /** + * This method stops the automatic clean up of the cache. + */ stopCacheCleanUps() { if (this.intervalID) { clearInterval(this.intervalID); diff --git a/test/test.ts b/test/test.ts index eabceab..91d0707 100644 --- a/test/test.ts +++ b/test/test.ts @@ -17,7 +17,6 @@ chai.use(chaiAsPromised); * Converts a JSON input to RDF and converts the stream to string. * @param input - JSON to convert to RDF. * @param converter - AnyToRdfConverter you want to reuse. If not provided a new one is created. - * @param cache - Use cache (optional, default is false). * @returns Converted input in string format. */ const convertJsonToRDF = async (input: any, converter?: AnyToRdfConverter): Promise => {