From 533451f061287e13dc4bba9290ad6f987db39aaf Mon Sep 17 00:00:00 2001 From: Lee Willis Date: Fri, 26 Aug 2016 14:33:05 +0100 Subject: [PATCH] Use transients as storage as a fallback. --- time-stack.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/time-stack.php b/time-stack.php index e710e9d..949b134 100644 --- a/time-stack.php +++ b/time-stack.php @@ -25,8 +25,10 @@ public static function get_data( $clear = false ) { if ( function_exists( 'apc_store' ) && apc_store( '__test', '123' ) ) { $data = apc_fetch( '_hm_all_stacks' ); - } else { + } elseif ( wp_using_ext_object_cache() ) { $data = wp_cache_get( '_hm_all_stacks' ); + } else { + $data = get_transient( '_hm_all_stacks' ); } if ( $clear ) @@ -39,8 +41,10 @@ public static function set_data( $data ) { if ( function_exists( 'apc_store' ) && apc_store( '__test', '123' ) ) { return apc_store( '_hm_all_stacks', $data, 60 ); - } else { + } elseif ( wp_using_ext_object_cache() ) { return wp_cache_set( '_hm_all_stacks', $data, null, 60 ); + } else { + return set_transient( '_hm_all_stacks', $data, 60 ); } }