wp_cache_add

函式
wp_cache_add ( $key, $data, $group = '', $expire = 0 )
引數
  • (int|string) $key The cache key to use for retrieval later.
    Required:
  • (mixed) $data The data to add to the cache.
    Required:
  • (string) $group Optional. The group to add the cache to. Enables the same key to be used across groups. Default empty.
    Required:
    Default: (empty)
  • (int) $expire Optional. When the cache data should expire, in seconds. Default 0 (no expiration).
    Required:
返回值
  • (bool) True on success, false if cache key and group already exist.
相關
  • WP_Object_Cache::add()
定義位置
相關方法
wp_cache_decrwp_cache_getwp_cache_setwp_headwp_cache_delete
引入
2.0.0
棄用
-

wp_cache_add: 這個函式在快取中儲存一個值,將其與指定的鍵相關聯。如果該鍵已經存在於快取中,該值將不會被覆蓋。如果該值被成功新增到快取中,該函式返回true。

將資料新增到快取中,如果快取鍵不已經存在的話。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_cache_add( $key, $data, $group = '', $expire = 0 ) {
global $wp_object_cache;
return $wp_object_cache->add( $key, $data, $group, (int) $expire );
}
function wp_cache_add( $key, $data, $group = '', $expire = 0 ) { global $wp_object_cache; return $wp_object_cache->add( $key, $data, $group, (int) $expire ); }
function wp_cache_add( $key, $data, $group = '', $expire = 0 ) {
	global $wp_object_cache;

	return $wp_object_cache->add( $key, $data, $group, (int) $expire );
}

常見問題

FAQs
檢視更多 >