0
0
Laravelframework~10 mins

Cache tags in Laravel - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to store a cache item with a tag.

Laravel
Cache::tags('[1]')->put('key', 'value', 60);
Drag options to blanks, or click blank then click option'
Ausers
Bsession
Ccache
Dconfig
Attempts:
3 left
💡 Hint
Common Mistakes
Using a method other than tags() to assign tags.
Passing an array instead of a string for a single tag.
2fill in blank
medium

Complete the code to retrieve a cached item with a tag.

Laravel
$value = Cache::tags('users')->[1]('key');
Drag options to blanks, or click blank then click option'
Aget
Bstore
Cput
Dforget
Attempts:
3 left
💡 Hint
Common Mistakes
Using put instead of get to retrieve data.
Using forget which deletes the cache.
3fill in blank
hard

Fix the error in the code to clear all cache items with the 'users' tag.

Laravel
Cache::tags('users')->[1]();
Drag options to blanks, or click blank then click option'
Aforget
Bflush
Cclear
Dremove
Attempts:
3 left
💡 Hint
Common Mistakes
Using clear which is not a valid method.
Using forget which only deletes one key.
4fill in blank
hard

Fill both blanks to store a cache item with multiple tags.

Laravel
Cache::tags([[1], [2]])->put('key', 'value', 120);
Drag options to blanks, or click blank then click option'
A'users'
B'settings'
C'config'
D'session'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing tags as a comma-separated string instead of an array.
Using invalid tag names.
5fill in blank
hard

Fill all three blanks to retrieve a cached item with multiple tags and a default value.

Laravel
$value = Cache::tags([[1], [2]])->get('key', [3]);
Drag options to blanks, or click blank then click option'
A'users'
B'settings'
C'default'
D'cache'
Attempts:
3 left
💡 Hint
Common Mistakes
Not passing tags as an array.
Omitting the default value parameter.