22/**
33 * Plugin Name: Tiny navigation menu cache (MU)
44 * Description: Cache nav menu's HTML content in persistent object cache.
5- * Version: 0.2.0
5+ * Version: 0.2.1
66 * Constants: TINY_CACHE_NAV_MENU_EXCLUDES
77 */
88
@@ -67,8 +67,7 @@ public function init() {
6767 */
6868 public function get_nav_menu ( $ nav_menu_html , $ args ) {
6969
70- $ enabled = $ this ->is_enabled ( $ args );
71- if ( $ enabled ) {
70+ if ( $ this ->is_enabled ( $ args ) ) {
7271 $ found = null ;
7372 $ cache = wp_cache_get ( $ this ->get_cache_key ( $ args ), self ::GROUP , false , $ found );
7473 if ( $ found ) {
@@ -87,8 +86,7 @@ public function get_nav_menu( $nav_menu_html, $args ) {
8786 */
8887 public function save_nav_menu ( $ nav_menu_html , $ args ) {
8988
90- $ enabled = $ this ->is_enabled ( $ args );
91- if ( $ enabled ) {
89+ if ( $ this ->is_enabled ( $ args ) ) {
9290 $ key = $ this ->get_cache_key ( $ args );
9391 wp_cache_set ( $ key , $ nav_menu_html , self ::GROUP , DAY_IN_SECONDS );
9492 $ this ->remember_key ( $ key );
@@ -111,13 +109,10 @@ public function flush_all() {
111109 private function remember_key ( $ key ) {
112110
113111 // @TODO Not atomic
114- $ found = null ;
112+ $ found = false ;
115113 $ key_list = wp_cache_get ( 'key_list ' , self ::GROUP , false , $ found );
116- if ( $ found ) {
117- $ key_list .= '| ' . $ key ;
118- } else {
119- $ key_list = $ key ;
120- }
114+
115+ $ key_list = $ found ? $ key_list . '| ' . $ key : $ key ;
121116 wp_cache_set ( 'key_list ' , $ key_list , self ::GROUP , DAY_IN_SECONDS );
122117 }
123118
0 commit comments