bandcamp-fetch/docs/api/classes/Cache.md

245 lines
4.1 KiB
Markdown
Raw Permalink Normal View History

2023-06-10 16:52:27 +02:00
[bandcamp-fetch](../README.md) / Cache
# Class: Cache
## Table of contents
### Constructors
- [constructor](Cache.md#constructor)
### Methods
- [clear](Cache.md#clear)
- [get](Cache.md#get)
- [getKeys](Cache.md#getkeys)
- [getMaxEntries](Cache.md#getmaxentries)
- [getOrSet](Cache.md#getorset)
- [put](Cache.md#put)
- [reduceEntries](Cache.md#reduceentries)
- [setMaxEntries](Cache.md#setmaxentries)
2023-06-10 16:52:27 +02:00
- [setTTL](Cache.md#setttl)
## Constructors
### constructor
**new Cache**(`ttl`, `maxEntries`)
#### Parameters
| Name | Type |
| :------ | :------ |
| `ttl` | `Record`<[`CacheDataType`](../enums/CacheDataType.md), `number`\> |
| `maxEntries` | `Record`<`string`, `number`\> |
#### Defined in
2023-10-29 18:25:17 +01:00
[lib/utils/Cache.ts:13](https://github.com/patrickkfkan/bandcamp-fetch/blob/7bb1899/src/lib/utils/Cache.ts#L13)
2023-06-10 16:52:27 +02:00
## Methods
### clear
**clear**(`type?`): `void`
2023-06-10 16:52:27 +02:00
#### Parameters
| Name | Type |
| :------ | :------ |
| `type?` | [`CacheDataType`](../enums/CacheDataType.md) |
#### Returns
`void`
#### Defined in
2023-10-29 18:25:17 +01:00
[lib/utils/Cache.ts:74](https://github.com/patrickkfkan/bandcamp-fetch/blob/7bb1899/src/lib/utils/Cache.ts#L74)
___
### get
**get**<`T`\>(`type`, `key`): `undefined` \| `T`
#### Type parameters
| Name |
| :------ |
| `T` |
#### Parameters
| Name | Type |
| :------ | :------ |
| `type` | [`CacheDataType`](../enums/CacheDataType.md) |
| `key` | `string` |
#### Returns
`undefined` \| `T`
#### Defined in
2023-10-29 18:25:17 +01:00
[lib/utils/Cache.ts:39](https://github.com/patrickkfkan/bandcamp-fetch/blob/7bb1899/src/lib/utils/Cache.ts#L39)
___
### getKeys
**getKeys**(`type`): `string`[]
#### Parameters
| Name | Type |
| :------ | :------ |
| `type` | [`CacheDataType`](../enums/CacheDataType.md) |
#### Returns
`string`[]
#### Defined in
2023-10-29 18:25:17 +01:00
[lib/utils/Cache.ts:70](https://github.com/patrickkfkan/bandcamp-fetch/blob/7bb1899/src/lib/utils/Cache.ts#L70)
___
### getMaxEntries
**getMaxEntries**(`type`): `number`
#### Parameters
| Name | Type |
| :------ | :------ |
| `type` | [`CacheDataType`](../enums/CacheDataType.md) |
#### Returns
`number`
#### Defined in
2023-10-29 18:25:17 +01:00
[lib/utils/Cache.ts:35](https://github.com/patrickkfkan/bandcamp-fetch/blob/7bb1899/src/lib/utils/Cache.ts#L35)
___
### getOrSet
**getOrSet**<`T`\>(`type`, `key`, `promiseCallback`): `Promise`<`T`\>
#### Type parameters
| Name |
| :------ |
| `T` |
#### Parameters
| Name | Type |
| :------ | :------ |
| `type` | [`CacheDataType`](../enums/CacheDataType.md) |
| `key` | `string` |
| `promiseCallback` | () => `Promise`<`T`\> |
#### Returns
`Promise`<`T`\>
#### Defined in
2023-10-29 18:25:17 +01:00
[lib/utils/Cache.ts:85](https://github.com/patrickkfkan/bandcamp-fetch/blob/7bb1899/src/lib/utils/Cache.ts#L85)
___
### put
**put**<`T`\>(`type`, `key`, `value`): `boolean`
#### Type parameters
| Name |
| :------ |
| `T` |
#### Parameters
| Name | Type |
| :------ | :------ |
| `type` | [`CacheDataType`](../enums/CacheDataType.md) |
| `key` | `string` |
| `value` | `T` |
#### Returns
`boolean`
#### Defined in
2023-10-29 18:25:17 +01:00
[lib/utils/Cache.ts:43](https://github.com/patrickkfkan/bandcamp-fetch/blob/7bb1899/src/lib/utils/Cache.ts#L43)
___
### reduceEntries
**reduceEntries**(`type`, `reduceTo?`): `void`
#### Parameters
| Name | Type |
| :------ | :------ |
| `type` | [`CacheDataType`](../enums/CacheDataType.md) |
| `reduceTo?` | `number` |
#### Returns
`void`
#### Defined in
2023-10-29 18:25:17 +01:00
[lib/utils/Cache.ts:58](https://github.com/patrickkfkan/bandcamp-fetch/blob/7bb1899/src/lib/utils/Cache.ts#L58)
2023-06-10 16:52:27 +02:00
___
### setMaxEntries
2023-06-10 16:52:27 +02:00
**setMaxEntries**(`type`, `maxEntries`): `void`
2023-06-10 16:52:27 +02:00
#### Parameters
| Name | Type |
| :------ | :------ |
| `type` | [`CacheDataType`](../enums/CacheDataType.md) |
| `maxEntries` | `number` |
2023-06-10 16:52:27 +02:00
#### Returns
`void`
#### Defined in
2023-10-29 18:25:17 +01:00
[lib/utils/Cache.ts:30](https://github.com/patrickkfkan/bandcamp-fetch/blob/7bb1899/src/lib/utils/Cache.ts#L30)
2023-06-10 16:52:27 +02:00
___
### setTTL
**setTTL**(`type`, `ttl`): `void`
2023-06-10 16:52:27 +02:00
#### Parameters
| Name | Type |
| :------ | :------ |
| `type` | [`CacheDataType`](../enums/CacheDataType.md) |
| `ttl` | `number` |
#### Returns
`void`
#### Defined in
2023-10-29 18:25:17 +01:00
[lib/utils/Cache.ts:21](https://github.com/patrickkfkan/bandcamp-fetch/blob/7bb1899/src/lib/utils/Cache.ts#L21)