Skip to content

Improve ProviderCache #904

Open
Open
@eugenekurasov

Description

@eugenekurasov

What are you think about add to ProviderCache flag isAllowEmptyResult?

For example:

$chain = new \Geocoder\Provider\Chain\Chain([
    // ...
]);
$cache = new \Geocoder\Provider\Cache\ProviderCache($chain, $cache, 86400);

When have exceptions from providers the chain catch and return empty ArrayCollection.
This result is saved for 24h. I think will be good point if I don't save empty results.

$result = $this->realProvider->geocodeQuery($query);
$this->cache->set($cacheKey, $result, $this->lifetime);

Here is example how I think can be:

         $result = $this->realProvider->geocodeQuery($query); 
         if (!$result->isEmpty() || $this->isAllowEmptyResult)) {
             $this->cache->set($cacheKey, $result, $this->lifetime);
         }

What are you think about it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions