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

Added cache clearing & setting cachePrefix for Aws S3 #336

Merged
merged 4 commits into from
Mar 6, 2014
Merged

Added cache clearing & setting cachePrefix for Aws S3 #336

merged 4 commits into from
Mar 6, 2014

Conversation

rvanlaarhoven
Copy link
Contributor

Not sure if this is the best solution, but I used a setter to get the cachePrefix to fix #269 & #251.
This would require adding the prefix to the resolver like;

acme.imagine.cache.resolver.amazon_s3:
        class: Liip\ImagineBundle\Imagine\Cache\Resolver\AwsS3Resolver
        arguments:
            - "@acme.amazon_s3"
            - "%amazon_s3.bucket%"
        tags:
            - { name: 'liip_imagine.cache.resolver', resolver: 'amazon_s3' }
        calls:
            - [setCachePrefix, ["%liip_imagine.cache_prefix%"]]

Anyway, it clears all files inside the predefined directory in your bucket when running the app/console cache:clear command.

@makasim
Copy link
Collaborator

makasim commented Mar 6, 2014

looks good to me

// TODO: implement cache clearing for Amazon S3 service
// Let's just avoid to clear the whole bucket if cache prefix is empty
if ($cachePrefix === '')
throw new \InvalidArgumentException("Cannot clear the Imagine cache because the cache_prefix is empty in your config.");
Copy link
Collaborator

Choose a reason for hiding this comment

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

please do nothing here, as exception is a BC break.

FYI: in 1.0 this method was removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean replacing the Exception with a simple return, like in the new commit?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, could add {} for if statement as it require PSR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

makasim added a commit that referenced this pull request Mar 6, 2014
Added cache clearing & setting cachePrefix for Aws S3
@makasim makasim merged commit c224ab9 into liip:master Mar 6, 2014
@makasim
Copy link
Collaborator

makasim commented Mar 6, 2014

thanks

@rvanlaarhoven rvanlaarhoven deleted the awscachefix branch March 13, 2014 18:26
@ribeiropaulor
Copy link
Contributor

Hello,

am I missing something or this improvement was overwritten in ( 8cd9e06 )?

It's not, for sure, in the last dev-master version of the repository.

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.

cache_prefix is ignored on S3
3 participants