Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Serializer][Cache] Return dev serializer cache #42107

Copy link
Copy link
Closed
@Foxprodev

Description

@Foxprodev
Issue body actions

Description
PR #41961 removed Class metadata cache from development environment (by default), but as @dunglas mentioned in discussion #40034

the dev environnement is already very slow on large projects. I'm not sure if it's a good idea (but I'm not strongly opposed to it either).

I was a little confused, because serializer is very usable feature in API development(and serializer is heart of api-platform).
I have an interactive map application with layer clustering and dynamic layer-in-view loading. Application produces multiple resource requests on each interaction (changing zoom, moving view) and it should be dramatically slow without cache in dev.

So I decided to find a way to invalidate metadata cache and found two ways:

  • Bundles can register resources using ContainerBuilder::addResource and Kernel checks resource freshness at the start of initialization. Can we add a user-defined resources? (at least FileResource and DirectoryResource)
  • More flexible and complex way is to create a service, which handles dynamic resource adding and invalidates cache pools separately depending on associated resources. For example: CacheClassMetadataFactory will add directory or file resources to this service associated with cache.serialzier pool. That is dev-only service of course and other services can add their resources to invalidate cache pools.

Example
Well, I ve forked #41961 bugdemonstrating repository and added a very naive invalidator service. It's just a concept, don't blame me if I am on a wrong way. There are still some unresolved problems and I know it (especially init and commit events binding).

https://github.com/Foxprodev/PR-40856
Foxprodev/PR-40856@6c21f94

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.