Support the ongoing development of Laravel.io →
posted 9 years ago
Cache
Last updated 2 years ago.
0

I would love to know for sure, but I would guess that, since tags are added to the keys, and not the other way around, they would get overriden.

Wouldn't an easier way be just to use:

Cache::forever('key'.$uniq, $var1);
Last updated 2 years ago.
0

This must be extremely easy to just try out? (I'm on iPhone)

Last updated 2 years ago.
0

christoffertyrefors said:

This must be extremely easy to just try out? (I'm on iPhone)

You would think.

I tried it but when it tossed and error I consulted the docs, http://laravel.com/docs/4.2/cache#cache-tags

Note: Cache tags are not supported when using the file or database cache drivers. Furthermore, when using multiple tags with caches that are stored "forever", performance will be best with a driver such as memcached, which automatically purges stale records.

But from the examples it appears it would work.

Last updated 2 years ago.
0

This is indeed easy to test. This is allowed and here are the results:

Cache::tags('a')->forever('key','test1'); 
Cache::tags('b')->forever('key','test2'); 

echo Cache::get('key');
// prints nothing

echo Cache::tags('a')->get('key');
// prints "test1"

echo Cache::tags('b')->get('key');
// prints "test2"
Last updated 2 years ago.
0

Wait, so I was wrong? Is it really that easy to uniquely cache things? This changes at least a few things then.

Last updated 2 years ago.
0

DaveMC08 said:

Wait, so I was wrong? Is it really that easy to uniquely cache things? This changes at least a few things then.

This appears to be how it functions. Nothing is overwritten which makes my life a lot easier.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

kcristella kcristella Joined 11 Oct 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.