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

Do not disable cache in dev #2629

Merged
merged 1 commit into from
Mar 20, 2019
Merged

Conversation

teohhanhui
Copy link
Contributor

@teohhanhui teohhanhui commented Mar 19, 2019

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #2593 (partially)
License MIT
Doc PR api-platform/docs#766

With the cache enabled, changing API resource metadata in dev still works without a manual cache:clear.

@maks-rafalko
Copy link
Contributor

Could you please explain what should be used instead? Or what are the defaults for prod/test environments?

It's not clear what the end user should do from the deprecation warning. Just remove and what is the alternative?

Thanks

@teohhanhui
Copy link
Contributor Author

teohhanhui commented Mar 19, 2019

Yes, just remove it. The cache is enabled.

There should not be a need to disable it in most cases. I'd consider that an advanced use case, so we don't need to guide you in such a case anyway.

@maks-rafalko
Copy link
Contributor

maks-rafalko commented Mar 19, 2019

The cache is enabled.

The question is what is the adapter used for each env: dev, test, prod?

From what I have learned in previous master, the default cache adapter was cache.system, which is, in our case, APCu. And we had to enable it explicitly, by setting api_platform.metadata_cache to true. In dev mode, it was overridden with ArrayAdapter.

What are the defaults now? Will api-platform use cache.system by default, even in dev mode? If so, how it will work "without a manual cache:clear"?

Hope it will help other people that will have the same questions ;)

@teohhanhui
Copy link
Contributor Author

teohhanhui commented Mar 19, 2019

What are the defaults now? Will api-platform use cache.system by default, even in dev mode?

Yes.

If so, how it will work "without a manual cache:clear"?

We've always been using the DirectoryResource so the container is automatically rebuilt when any file in the directory is modified (the directories specified in mapping > paths option of API Platform config). If I understand correctly, the cache invalidation is taken care of by Symfony. (We do have apcu enabled in api-platform/demo, which I tested with. So I think it works as intended.)

However, perhaps adding a new file would require a manual cache:clear, just like for Symfony Serializer / Validator metadata. (Not sure about this point. I'll try to verify.)

Copy link
Member

@dunglas dunglas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@soyuka soyuka merged commit 049d5aa into api-platform:2.4 Mar 20, 2019
@soyuka
Copy link
Member

soyuka commented Mar 20, 2019

Thanks @teohhanhui !

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

Successfully merging this pull request may close these issues.

5 participants