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

FileStorage Adapter #2175

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

FileStorage Adapter #2175

wants to merge 2 commits into from

Conversation

OleVik
Copy link
Contributor

@OleVik OleVik commented Sep 9, 2018

PSR-16 compliant adapter for abstract handling of transient and persistent files. The difference from FileCache.php is that the implementation is not outright set up for caching with Grav's normal setup, but rather a destination must be explicitly given. Otherwise they largely overlap.

For an example use, see this SchemaBlueprintCommand.php, where plugin option determine the permanence of the file. Ie., transient for normal /cache, native for within-plugin (busted on new version), or persist for /user/data. This command intentionally deletes the file regardless, elsewhere it is used to check for existence or recreate (planned features in the plugin).

@mahagr Thoughts? I dropped the Symfony-components.

PSR-16 compliant adapter for abstract handling of transient and persistent files.
@rhukster rhukster requested a review from mahagr October 23, 2018 13:25
@mahagr
Copy link
Member

mahagr commented Oct 23, 2018

Is there a way to extend the FileCache and just override constructor and getFile() methods? It may need AbstractFileCache base class without the constructor, though :) Think about it.

Also, make sure that cache allows persistent caching without any timeouts.

@OleVik
Copy link
Contributor Author

OleVik commented Oct 27, 2018

There is, largely, but not without switching from private to protected on FileCache's init() and write(). Also, is it preferable to keep the ttl and key in the output when the file is stored - and not cached - like this? Because of doSet(), both will occupy a line each.

Eg., from the reference-command in the initial proposal, the resulting files ends up:

1540633949
Event.schema.json
s:389:"{"Schema":{"Thing":{"Event":{"BusinessEvent":null,"ChildrensEvent":null,"ComedyEvent":null,"DanceEvent":null,"DeliveryEvent":null,"EducationEvent":null,"Festival":null,"FoodEvent":null,"LiteraryEvent":null,"MusicEvent":null,"PublicationEvent":{"BroadcastEvent":null,"OnDemandEvent":null},"SaleEvent":null,"SocialEvent":null,"SportsEvent":null,"TheaterEvent":null,"VisualArtsEvent":null}}}}";

Wouldn't I also have to override write() to preempt the ttl-check when extending FileCache?

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

Successfully merging this pull request may close these issues.

2 participants