0

when setting the cache method to redis it seems to increase runtime for loading a spreadsheet and reading etc.

before i use any part of PHPSpreadsheet classes i run the following

    if(CACHE_ON){
                    $client = new \Redis();
                    $client->connect(CACHE_HOST, 6379);
                    $pool = new \Cache\Adapter\Redis\RedisCachePool($client);
                    $simpleCache = new \Cache\Bridge\SimpleCache\SimpleCacheBridge($pool);
                    \PhpOffice\PhpSpreadsheet\Settings::setCache($simpleCache);
                }
//...
try {
                $fileType = IOFactory::identify($uploadFile);
            } catch(\PhpOffice\PhpSpreadsheet\Reader\Exception $e) {
                $message = 'Input file is not an Excel Workbook. Please save as an Excel Workbook and try again.';
                $this->log->error('Error loading file: '.$e->getMessage() . mime_content_type($uploadFile) . $message);
                return ['error'=>true,'message'=>$message];
            }

I don't understand why it increases time by 1/2 seconds. is this normal behaviour or do i need to update anything in redis?

shorif2000
  • 2,582
  • 12
  • 65
  • 137

1 Answers1

0

Maybe you can use redis connection pool, don't use redis when need, you can prepare in advance.

Ryoma
  • 64
  • 1
  • 9
  • 1
    im not sure what you mean by "don't use redis when need, you can prepare in advance" – shorif2000 May 14 '19 at 09:29
  • I mean you shouldn't new Redis every time, you can new Redis in advance. And maybe you can provide more code. – Ryoma May 14 '19 at 11:44
  • this is the starting point of my code. how would i access redis if i dont declare it? i use https://www.phpfastcache.com/ as well but not sure how to use that in here – shorif2000 May 14 '19 at 13:12
  • I don't know more about your code. I have a problem need sure: Do you need New Redis Client every time when you receive request? – Ryoma May 14 '19 at 13:27
  • this is to process the php spreadsheet and i thought caching with Redis will speed up large spreedsheets? if i ran the above code on `CLI` the time to complete is increased when using redis as a cache. – shorif2000 May 14 '19 at 13:45