Skip to content

Propose a way for user to use symfony cache with #70

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
wants to merge 1 commit into from

Conversation

cedriclombardot
Copy link
Contributor

To not regenerate each time blurhash

Q A
Bug fix? no
New feature? no
License MIT

Just for helping devs implementing cache with symfony/cache

$cacheKey = $slugger->slug(implode('-', func_get_args()));

$value = $this->cache->get($cacheKey, function (ItemInterface $item) use ($filename, $width, $height, $encodingWidth, $encodingHeight) {
if (!$item->isHit()) {
Copy link
Member

Choose a reason for hiding this comment

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

there is no need for this check inside a cache callback


$value = $this->cache->get($cacheKey, function (ItemInterface $item) use ($filename, $width, $height, $encodingWidth, $encodingHeight) {
if (!$item->isHit()) {
$item->set(
Copy link
Member

Choose a reason for hiding this comment

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

neither this is needed - just return the value, the pool will set the item :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh thanks for the review, i missread the doc :)

@cedriclombardot cedriclombardot force-pushed the patch-1 branch 4 times, most recently from 749b546 to c44e958 Compare March 23, 2021 19:26
To not regenerate each time blurhash
Comment on lines +168 to +169
public function __construct(private BlurHashInterface $blurHash, private CacheInterface $cache)
{}
Copy link
Member

Choose a reason for hiding this comment

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

This is PHP 8 code and I don't think we want documentation/examples to be written with.
I think it would be better to write code compatible with the lowest PHP requirement which is 7.2.5.

WDYT?

@weaverryan
Copy link
Member

I like this PR... but can't we go further? It feels like the blurhash should always cache. Or, at the very worst, you just add one line of configuration (e.g. to point it at a cache pool, perhaps) and caching is all setup.

@Kocal
Copy link
Member

Kocal commented Oct 11, 2024

Hi, I'm sorry but I've just seen this PR this exists, and BlurHash caching has been implemented in #1755.
I'm closing the PR, but thanks for the contribution!

@Kocal Kocal closed this Oct 11, 2024
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.

4 participants