Home > front end >  what is naming convention for laravel cache tags multi words?
what is naming convention for laravel cache tags multi words?

Time:01-11

i want to use best naming convention for cache tag key but i could not find it. i checked in official docs and other websites for example for cache tag but i could find only 1 word tags , should i use same casing as variable name or other format like globalMenus or should i use global:menus or global_menus. i am looking for best practices.
https://laravel.com/docs/9.x/cache#cache-tags

Cache::tags(['globalmenus')->get('slider_media');

CodePudding user response:

I would go with kebab case for cache tags as this is how Laravel uses Blade component tags in rendering components

CodePudding user response:

Anything would work really. But if you look at how Laravel does it you'll see:

cache:tag:calls:key
cache:63be6acad:standard_ref
app:horizon:measured_queues
app:horizon:completed_jobs

So I'd say use underscores for separating words and colons for separating groups

https://github.com/laravel/framework/blob/b9203fca96960ef9cd8860cb4ec99d1279353a8d/tests/Cache/CacheTaggedCacheTest.php#L236

  • Related