Tatvic / RGoogleAnalytics

R Library to easily extract data from the Google Analytics API into R
227 stars 147 forks source link

Bug in caching design #44

Open davejacobs opened 6 years ago

davejacobs commented 6 years ago

I love this library—it's made analyzing GA data so much easier for me.

There is a bug with how caching works. Currently, the result of a query is cached, regardless of the return status. The issue is that the next time the query runs (with cache = TRUE), you'll relive the error code, even if the error came from rate limiting. What's more, because of how RGoogleAnalytics builds up the cache file name, it's not obvious how to quickly delete just the right file. This means that if you've built up a solid cache of responses over time for historical reports, you either need to spend time discovering the filename or need to delete the entire cache.

I could see a couple of better solutions here:

  1. Don't cache responses with error codes
  2. Add a 'delete cache' function for particular query params
  3. Use a library like memoise to make cache management easier

What do you think?