Search code examples
phparrayscachingfat-free-framework

In Fat Free Framework, how can I differentiate Cached Value vs. Array in config.ini?


I have seen the example posted by the author of FatFree Framework on setting cache values in routes and framework variables:

[globals]
foo=bar,86400 // variable cached for 24 hours

[routes]
GET /foo=Bar->baz,3600 // route cached for 1 hour

But in the Fat Free Framework documentation, we have this example to set arrays

; this is also an array
items=7,8,9
; array with mixed elements
mix="this",123.45,FALSE

So, my question is, how can I differentiate if I want a value cached or Arrayed?


Solution

  • The comma separated values in the [globals] section indicate arrays only.

    It looks like @bcosca mistakenly wrote his comment. The caching syntax for globals cannot work with the current codebase (internally the set method is called with 2 arguments only).

    To make things clear, here's the meaning of commas for both sections:

    [globals]
    foo=bar,86400 //define an array
    
    [routes]
    GET /foo=Bar->baz,3600 //cache route for 1h
    GET /foo=Bar->baz,0,56 //limits bandwith to 56 kps
    

    In other words, the previous configuration file is equivalent to:

    $f3->set('foo',array('bar',86400));
    $f3->route('GET /foo','Bar->baz',3600);
    $f3->route('GET /foo','Bar->baz',0,56);