geocoder-php / geocoder-php/Geocoder
Improve ProviderCache
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 4k
- Forks
- 525
- Avg merge
- 8m
- Merged PRs (30d)
- 1
Description
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.
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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/Provider/Cache/ProviderCache.php, especially the cache write around lines 65–66, and trace how Chain returns an empty ArrayCollection after provider exceptions. Define how the proposed isAllowEmptyResult option should affect caching, then verify that empty results are skipped by default and stored when the option permits them.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100