Preferred method to store PHP arrays (json_encode vs serialize)

前端 未结 20 2285
孤独总比滥情好
孤独总比滥情好 2020-11-22 05:55

I need to store a multi-dimensional associative array of data in a flat file for caching purposes. I might occasionally come across the need to convert it to JSON for use in

20条回答
  •  野的像风
    2020-11-22 06:49

    I would suggest you to use Super Cache, which is a file cache mechanism which won't use json_encode or serialize. It is simple to use and really fast compared to other PHP Cache mechanism.

    https://packagist.org/packages/smart-php/super-cache

    Ex:

    ')->set('');
    sCache::cache('myKey')->set('Key_value');
    
    //Retrieving cache value with a key
    echo sCache::cache('myKey')->get();
    ?>
    

提交回复
热议问题