Skip to content

Commit

Permalink
Merge pull request #383 from V4Fire/fix/provider-cache
Browse files Browse the repository at this point in the history
Fix/provider cache
  • Loading branch information
Anastasiia Razumova authored Dec 19, 2023
2 parents 90d1f87 + bc208c9 commit 44bf4e8
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ Changelog
_Note: Gaps between patch versions are faulty, broken or test releases._

## v4.0.0-alpha.16 (2023-12-19)

#### :bug: Bug Fix

* Fixed cache initialization for providers

## v4.0.0-alpha.15 (2023-11-26)

#### :rocket: New Feature
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "lib/core/index.js",
"typings": "index.d.ts",
"license": "MIT",
"version": "4.0.0-alpha.15",
"version": "4.0.0-alpha.16",
"author": "kobezzza <[email protected]> (https://github.com/kobezzza)",
"repository": {
"type": "git",
Expand Down
6 changes: 6 additions & 0 deletions src/core/data/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Changelog
> - :house: [Internal]
> - :nail_care: [Polish]
## v4.0.0-alpha.16 (2023-12-19)

#### :bug: Bug Fix

* Fixed cache initialization for providers

## v4.0.0-alpha.12 (2023-10-17)

#### :rocket: New Feature
Expand Down
4 changes: 3 additions & 1 deletion src/core/data/interface/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ export interface ProviderOptions {
socket?: boolean;

/**
* If false, the instance of the data provider will not be cached
* By default, all instances of data providers are created as singletons
* to enable efficient caching between consumers.
* Setting this option to false will disable this behavior.
*/
singleton?: boolean;
}
Expand Down
5 changes: 3 additions & 2 deletions src/core/data/modules/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,16 @@ export default abstract class Provider extends ParamsProvider implements IProvid
id = this.getCacheKey(opts),
cacheVal = instanceCache[id];

if (opts.singleton === false) {
if (opts.singleton !== false) {
if (cacheVal != null) {
return <this>cacheVal;
}

instanceCache[id] = this;
requestCache[id] = Object.createDict();
}

requestCache[id] = Object.createDict();

this.cacheId = id;
this.params = opts;

Expand Down

0 comments on commit 44bf4e8

Please sign in to comment.