Instagram-php-scraper: Calling many times CacheManager::getInstance()

Created on 21 Oct 2017  路  5Comments  路  Source: postaddictme/instagram-php-scraper

When calling getPaginateMediasByTag too often (4-5 times a minute), I'm getting this error:

"[ErrorException]
[Files] 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
"

Is this some config issue? How to fix it?

wontfix

All 5 comments

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Same for me

In CacheManager.php line 119:

[Files] 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

I saw that multiple users has the same problem with this lib, and anyone has been able to fix it
:(

In InstagramScraper.php, change
private static $instanceCache;
to
private static $instanceCache = null;
Then, in public static function withCredentials(), change:
static::$instanceCache = CacheManager::getInstance('files');
to

if (static::$instanceCache == null) {
    static::$instanceCache = CacheManager::getInstance('files');
}

@adgray worked! thanks!

Just one thing, is not InstagramScraper.php file, is Instagram.php

vendor/raiym/instagram-php-scraper/src/Instagram.php

Why this was never fixed?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pauloamorimbr picture pauloamorimbr  路  7Comments

kiskaserver picture kiskaserver  路  4Comments

waffle9012 picture waffle9012  路  6Comments

juangrimm picture juangrimm  路  8Comments

phoenixh picture phoenixh  路  5Comments