Closed mitmelon closed 3 years ago
Hello curious contributor ! Since it seems to be your first contribution, make sure that you've been:
Hello,
The issue is on your side: Why do you have two different functions calling phpfastcache in the exact same way ? It's an implementation design issue, not a phpfastcache issue.
This is how you should implement it:
function one(){
cache();
}
function two(){
cache();
}
function cache(){
$this->internalCacheInstance = CacheManager::getInstance($driver, $config);
}
Cheers, Georges
Hello,
The issue is on your side: Why do you have two different functions calling phpfastcache in the exact same way ? It's an implementation design issue, not a phpfastcache issue.
This is how you should implement it:
function one(){ cache(); } function two(){ cache(); } function cache(){ $this->internalCacheInstance = CacheManager::getInstance($driver, $config); }
Cheers, Georges
Even after following your examples same error is still showing....
Calling the two functions at the same time results in PHP Notice: [Sqlite] Calling many times CacheManager::getInstance() for already instanced drivers is a bad practice and have a significant impact on performances. See https://github.com/PHPSocialNetwork/phpfastcache/wiki/[V5]-Why-calling-getInstance%28%29-each-time-is-a-bad-practice-%3F
When i called one() and two in two separate classes... The error above always show.... So its a bug...
You can try replicating the issue to see what am talking about... Call both one() and two() multiple times and show your error logs..
No it's not a bug, it's on purpose.
You should not call for the same cache instance multiple times along your script.
You must store the cacheInstance somewhere in your project and re-use it depends your needs.
So no it's not a bug, but an implementation issue on your side.
Getting instance ID is impossible....
How do you know an instance has been called to prevent calling twice...
Lets assume i have two functions performing this below
Avoiding this error is impossible on two separate classes running those functions is hard...
The only method applicable is to create a function into CacheManager that let us find instanceID to cross check if an instance has been called or not... If called then return CacheManager object if not set it...
Please remove this functionality from CacheManager if the above could not be implemented...