8000 How to get the modification/creation time from a cache entry? · Issue #21275 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

How to get the modification/creation time from a cache entry? #21275

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

Closed
stephan-v opened this issue Jan 13, 2017 · 5 comments
Closed

How to get the modification/creation time from a cache entry? #21275

stephan-v opened this issue Jan 13, 2017 · 5 comments

Comments

@stephan-v
Copy link
Q A
Bug report? no
Feature request? no
BC Break report? no
RFC? no
Symfony version x.y.z

Hi,

I have a question about using the symfony cache component in a project of mine.

I am using the YAML decoder to decode a YAML file of mine to a PHP array. In turn, this php array is being used as the value for a cache entry with the Symfony cache component.

It all works perfectly fine. The problem is that I need update the cache entry when my YAML file has been changed. To do this I need to get the last modification time from the cache entry and compare it to that of my YAML file.

Currently I don't see any method to get a creation of modification timestamp. I however do see a creation timestamp on my cache entry, similar to this:

1515867059
<CacheEntryName>
<SerializedData>

Getting a modification time would be something that could prove extremely helpful. Is there any way to solve my problem with the current Symfony cache implemtation?

If I could get the absolute cache path from the cache item I could also get the modification time myself, but I also do not see any method for this.

@nicolas-grekas
Copy link
Member

Symfony Cache implements PSR-6, and PSR-6 does not provide any mean to get this date back.
This means it's your responsibility to store the date as another item key.

@javiereguiluz
Copy link
Member

@nicolas-grekas at the beginning, Symfony Cache was a strict PSR-6 implementation ... but lately we added some features and we are not PSR-6 strict. So, maybe, if we consider this a useful feature, we could add it, right?

@stephan-v
Copy link
Author

@nicolas-grekas I was afraid so. Too bad because it would be really helpful. Thanks for taking your time to read my question!

@stephan-v
Copy link
Author

@javiereguiluz It seems really helpful, especially since Symfony already has a YAML decoder available.

Let's say you have YAML config file that you want to cache, you would have no immediate way to rewrite to the cache after a file change to the YAML file without having the modification time.

@nicolas-grekas
Copy link
Member

@javiereguiluz why not, but as in #19728, it'd be great to do this in coordination with others so that it ends up in the fig's hands. So, please open an RFC if you mind.
I'm closing this issue for now since it's "solved".

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

No branches or pull requests

3 participants
0