[WordPress] 外掛分享: DP Simple Cache

首頁外掛目錄 › DP Simple Cache
全新外掛
安裝啟用
尚無評分
5189 天前
最後更新
問題解決
WordPress 2.5+ v0.4 上架:2011-12-30

內容簡介

D(ifferent)P(lace) Simple Cache 是一款 WordPress 外掛,可實現在會話級別上對對象進行簡單快取。

dpwpsimplecache 提供一個名為 $dpcache 的全域變量,它是 DP_Cache 類別的實例,已經設置為與 $_SESSION 通訊。在使用任何自定義函數之前,請始終使用全域 $ dpcache 變量(記住在使用它之前宣告全域 $ dpcache)。

如果您不想將會話跟踪到數據庫中,請將 $USE_DB_SESSION_MANAGER 全域變量設置為 0

global $USE_DB_SESSION_MANAGER; $USE_DB_SESSION_MANAGER = 0; // 預設為 1

插入對象:

$dpcache->set($key,$object);

獲取對象:

$object = $dpcache->set($key);

計算活躍用戶數:

$count_users = $dpcache->get_sessions_number();

計算當前用戶 $_SESSION 中的對象數:

$dpcache->get_statistics();

獲得當前用戶 $_SESSION 中的所有對象:

$dpcache->get_all_values();

測試當前用戶 $_SESSION 中是否存在一個對象:

$dpcache->contais($key);

刪除所有對象。如果 $all 參數設置為 false,該方法僅刪除當前用戶的 $_SESSION,如果為 true,則截斷整個表(預設為 false):

$dpcache->flush();

打印有關所有對象的人類可讀信息:

$dpcache->inspect();

刪除當前用戶 $_SESSION 中的一個對象:

$dpcache->delete($key);

通過 ID 刪除單個會話:

$dpcache->invalidate_single_session($sessid);

顯示當前活躍會話數:

<?php echo dpscache_active_users(); ?>

在任何時候,透過管理頁面,您可以:

查看當前用戶快取中的所有對象
刪除當前用戶快取中的所有對象
強制刪除所有會話
強制刪除單個會話

您可以在GitHub上找到最新版本。

外掛標籤

開發者團隊

⬇ 下載最新版 (v0.4) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「DP Simple Cache」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

D(ifferent)P(lace) Simple Cache is a WordPress plugin to implement a simple cache of objects at session level.
dpwpsimplecache provides a global variable $dpcache, which is an instantiation of the class DP_Cache already set up to talk to the $_SESSION. Always use the global $dpcache variable (Remember to globalize $dpcache before using it in any custom functions).
If you don’t want to track sessions into db set the $USE_DB_SESSION_MANAGER global variable to 0
global $USE_DB_SESSION_MANAGER;
$USE_DB_SESSION_MANAGER = 0; // default 1

Insert object;
$dpcache->set($key,$object);

Get object:
$object = $dpcache->set($key);

Count active users:
$count_users = $dpcache->get_sessions_number();

Count objects in the current user’s $_SESSION:
$dpcache->get_statistics();

Get all objects in the current user’s $_SESSION:
$dpcache->get_all_values();

Test if an object exist in the current user’s $_SESSION:
$dpcache->contais($key);

Delete all objects. If the $all parameter is set to false the method delete only the current user’s $_SESSION, if true truncate the entire table (default false):
$dpcache->flush();

Prints human-readable information about all objects:
$dpcache->inspect();

Delete an object in the current user’s $_SESSION:
$dpcache->delete($key);

Delete single session by ID:
$dpcache->invalidate_single_session($sessid);

Prints the number of active sessions:

At any time, through the administrative page, you can:

see all objects in the current user cache
delete all objects in the current user cache
force the deletion of all sessions
force the deletion of a single session

You can find the latest release on GitHub

延伸相關外掛

文章
Filter
Mastodon