SimpleResponseCache for Lime

Hi @artur
Does the SimpleResponseCache add-on work with the Lime app?

The SimpleResponseCache addon is caching request results for API calls.

What exactly do you mean by “working with the Lime app”? What do you want to achieve or what do you expect it to do?

Thank you. With the Lime app (ships with and is built into Cockpit) one can retrieve collection data, like this for example:
$posts = cockpit(‘collections’)->find(‘articles’);
There is no way to cache these “calls”, right?!

I see.

The SimpleResponseCache addons’ caching mechanism is triggered when an API call is made with the parameter rspc set to a truthy value.

It only caches the generated output on the request, not the actual result of the request to the DB.

You could use the addons code as base and modifiy it, so that it caches results based on a hash over the requested collection and filter options.

You’d be using the triggers

  'collections.find.after'
  'collections.find.before'

It could follow the logic

on ‘collections.find.before’

  • hash over collectionName + filterOptions
  • check if hash exists
  • if yes → change filter options to some simple request e.g. filter[id]=-1 which will cause the query to “fail fast”

on ‘collections.find.after’

  • hash over collectionName + filterOptions
  • check if hash exists
  • if yes → return hashed result instead of “failed” request
  • if no → cache and return result

Amazing. Thank you for a very thorough answer - much appreciated.