From 6c83b206481781159339628b7fec2f287c648a68 Mon Sep 17 00:00:00 2001 From: shahar-y Date: Wed, 23 Mar 2022 14:54:05 +0300 Subject: [PATCH] updated README --- README.md | 31 +++++++++++++++++++++++++++++++ src/paramTypes.ts | 10 +++++++--- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 850ec2c..cec19ac 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,37 @@ allowing automatic cache update and expiration according to the user's needs. `npm i --save try-cache` +## Options + +### Initiation options + +``` +/** + * @param silent - if true, don't log anything to the console. Defaults to false. + * @param expire - the default expiration time in seconds. Defaults to 5 mins. + */ +export type TCOptions = { + silent: boolean; + expire: number; +}; +``` + +### Operation Options + +``` +/** + * @param expire - the expiration time in seconds for the specific operation. Default to TCOptions' expire. + * @param callbackFunction - the function to call if the retrieveFunction throws an error after cache failed. Defaults to "do nothing". + * @param forceDB - if true, will force the retrieveFunction to be called even if the key is found in cache. Defaults to false. + */ +export type OperationOptions = { + expire: number; + callbackFunction: Function; + forceDB: boolean; +}; + +``` + ## Usage Example ``` diff --git a/src/paramTypes.ts b/src/paramTypes.ts index e514044..5ab0978 100644 --- a/src/paramTypes.ts +++ b/src/paramTypes.ts @@ -1,12 +1,16 @@ +/** + * @param silent - if true, don't log anything to the console + * @param expire - the default expiration time in seconds + */ export type TCOptions = { silent: boolean; expire: number; }; /** - * expire - the expiration time in seconds. - * callbackFunction - the function to call if the retrieveFunction throws an error after cache failed. - * forceDB - if true, will force the retrieveFunction to be called even if the key is found in cache. Defaults to false. + * @param expire - the expiration time in seconds. + * @param callbackFunction - the function to call if the retrieveFunction throws an error after cache failed. + * @param forceDB - if true, will force the retrieveFunction to be called even if the key is found in cache. Defaults to false. */ export type OperationOptions = { expire: number;