skip to Main Content

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');

2

Answers


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

    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search