Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query Caching #335

Open
alexc-jeromes opened this issue Aug 8, 2024 · 1 comment
Open

Query Caching #335

alexc-jeromes opened this issue Aug 8, 2024 · 1 comment
Labels
feature request New feature or request

Comments

@alexc-jeromes
Copy link

Description

The overhead for queries on each page is heavy. Would it be possible to add hooks which enable caching, which busts on insert/update/delete?

These are the queries just on one simple page:

  • select * from "statamic"."global_sets"
  • select * from "statamic"."blueprints" where "namespace" is null and "handle" = 'user' limit 1
  • select * from "statamic"."navigations" where "handle" = 'sidebar' limit 1
  • select * from "statamic"."trees" where "handle" = 'sidebar' and "type" = 'navigation' and "locale" = 'default' limit 1
  • select * from "statamic"."entries" where "id" in ([snipped for brevity])
  • select * from "statamic"."collections" where "handle" = 'pages' limit 1
  • select * from "statamic"."blueprints" where "namespace" = 'collections.pages'
  • select * from "statamic"."blueprints" where "namespace" = 'navigation'
  • select * from "statamic"."trees" where "handle" = 'pages' and "locale" = 'default' and "type" = 'collection' limit 1
  • select "id" from "statamic"."entries" where "collection" = 'pages' and "site" = 'default'
  • select * from "statamic"."navigations" where "handle" = 'top_bar' limit 1
  • select * from "statamic"."trees" where "handle" = 'top_bar' and "type" = 'navigation' and "locale" = 'default' limit 1
  • select * from "statamic"."entries" where "id" in ('[snipped]')

Something like this in the config, using mins:

'caching' => [
    'global' => 60, 
    'blueprints' => 60, 
    'collection' => 60, 
    'navigations' => 60, 
    'trees' => 60, 
    'entries' => 60, 
],
@alexc-jeromes alexc-jeromes added the feature request New feature or request label Aug 8, 2024
@ryanmitchell
Copy link
Contributor

We already pretty aggressively blink query results so that per page queries are (mostly) only run once.

Caching over a longer time period is pretty opinionated and your requirements/wants are likely to be different to those of other users. Creating invalidation rules that keep everyone happy would be a bit of a minefield.

There’s nothing stopping you binding your own models or even repositories and adding caching at that level. There are some laravel packages that provide support at the model level.

in short I feel you already have the capability to do this as things stand, albeit you need to code it yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants