0
0
Laravelframework~10 mins

Cache drivers (file, Redis, Memcached) 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 set a cache value using the file driver.

Laravel
Cache::store('[1]')->put('key', 'value', 600);
Drag options to blanks, or click blank then click option'
Aredis
Bfile
Cmemcached
Ddatabase
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'redis' or 'memcached' without having those services configured.
Confusing 'database' driver with file driver.
2fill in blank
medium

Complete the code to retrieve a cached value from Redis driver.

Laravel
$value = Cache::store('[1]')->get('key');
Drag options to blanks, or click blank then click option'
Aredis
Bfile
Cmemcached
Darray
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'file' driver name when intending to use Redis.
Using 'array' driver which is not persistent.
3fill in blank
hard

Fix the error in the code to use Memcached driver for caching.

Laravel
Cache::store('[1]')->put('session', $data, 3600);
Drag options to blanks, or click blank then click option'
Aredis
Bfile
Cmemcached
Ddatabase
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'memcache' instead of 'memcached'.
Using 'redis' or 'file' driver names by mistake.
4fill in blank
hard

Fill both blanks to create a cache key with prefix and set it using Redis driver.

Laravel
Cache::store('[1]')->put('[2]_user', $userData, 120);
Drag options to blanks, or click blank then click option'
Aredis
Bfile
Csession
Dmemcached
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'file' driver with Redis key prefix.
Using wrong prefixes that do not match the cache purpose.
5fill in blank
hard

Fill all three blanks to retrieve a cached value with fallback using Memcached driver.

Laravel
$value = Cache::store('[1]')->remember('[2]', 300, function() { return [3]; });
Drag options to blanks, or click blank then click option'
Amemcached
Buser_profile
CUser::find(1)
Dredis
Attempts:
3 left
💡 Hint
Common Mistakes
Using Redis driver name instead of Memcached.
Using invalid cache keys or missing fallback function.