device-detector icon indicating copy to clipboard operation
device-detector copied to clipboard

Recommend caching strategy is no longer valid

Open andrewjmead opened this issue 10 months ago • 1 comments

Hey, folks. Thanks for the great library 🙂

I looks to me that the optional caching strategy recommended in readme.md is no longer valid. It seems that setCache hasn't directly accepted \Doctrine\Common\Cache\CacheProvider since version 3.13.1. For reference, here's the version of setCache in 3.13.1 and here's the next version which is setCache in 4.0.0.

As you can see, it now requires the type to conform to CacheInterface. This is not reflected in the docs.

I was opening this issue to (1) confirm it is an actual issue with the docs and (2) offer to create a PR that addresses it by updating readme.md.

The current recommendation is:

$dd->setCache(new Doctrine\Common\Cache\PhpFileCache('./tmp/'));

I was hoping to update it to:

$dd->setCache(
    new DoctrineBridge(
        new Doctrine\Common\Cache\PhpFileCache('./tmp/')
    )
);

Introducing DoctrineBridge fixed the error I was originally getting.

Here is the current readme.md recommendation for reference:

// OPTIONAL: Set caching method
// By default static cache is used, which works best within one php process (memory array caching)
// To cache across requests use caching in files or memcache
// $dd->setCache(new Doctrine\Common\Cache\PhpFileCache('./tmp/'));

Let me know your thoughts.

andrewjmead avatar Aug 30 '23 19:08 andrewjmead