1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | <?php $getResultExpire = <span class = "auto-style1" >$cacheService->get( "name" );</span> echo "Get from cache:" . $getResultExpire; echo "<br>" ; echo "Set value to cache." ; echo "<br>" ; $cacheService-><span class = "auto-style1" >set( "name" , "Jerry" , 10 );</span> $getResult = $cacheService->get( "name" ); echo "Get from cache: " . $getResult; echo "<br>" ; echo "Delete value from cache" ; echo "<br>" ; <span class = "auto-style1" >$cacheService->delete( "name" );</span> $getResultDelete = $cacheService->get( "name" ); echo "After delete: " . $getResultDelete; echo "<br>" ; echo "Set Array to cache: " ; echo "<br>" ; $array = array( "name" => "jerry" , "address" => "hangzhou" ); $cacheService->set( "jerry" , $array, 10 ); $resultArrayMap = $cacheService->get( "jerry" ); echo $resultArrayMap[ 'address' ]; |
注:set方法的第3个参数是缓存超时时间,单位是秒。这个参数可以不传,使用默认值,是最大整数。但如果传这个参数,必须在10天以内。 并且key中不要含有" " 、"\n"、"\r"、"0" 等特殊字符