caffeinated / menus

:pushpin: Menu generator package for the Laravel framework
https://caffeinatedpackages.com
132 stars 59 forks source link

Menu Cache? #83

Open piperone opened 8 years ago

piperone commented 8 years ago

Do you have any suggestions with regards to handling caching a menu with this package? I recently had to move away from the "file-based" way of adding menuitems and put them inside a DB instead. Now I'd like to eliminate the extra queries and, if possible, the menu-building process for each request instead. My menu doesn't change that often anyway so, cacheing seems like a good idea to me.

I tried the most straightforward approach first:

$myMenu = Cache::remember('menu', $minutes, function(){
    return Menu::make('myMenu', function(){
        //
    });
})

But this results in:

Exception in FileStore.php line 100:
Serialization of 'Closure' is not allowed

Is there a good way to achieve this, or something similar?

piperone commented 7 years ago

No suggestions at all for this?