Skip to content

Commit

Permalink
updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
Shahar-Y committed Mar 23, 2022
1 parent 03a3a7c commit 6c83b20
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

```
Expand Down
10 changes: 7 additions & 3 deletions src/paramTypes.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 6c83b20

Please sign in to comment.