function user_stats_cache_set in User Stats 6
Same name and namespace in other branches
- 7 user_stats.module \user_stats_cache_set()
Store a value in the non-persistent User Stats cache.
If the function is called with no arguments, the entire cache is returned without being cleared.
The User Stats cache is a static array, which is why we call it non-persistent. The array structure is: $user_stats_cache[$uid][$type] = $value.
Parameters
$type: The type of statistic being stored, this corresponds to the statistic types used by user_stats_get_stats(), and one extra used to reset the cache: 'reset'.
$uid: Unique ID of the user who's statistic is being stored. If the type is set to 'reset', this user id will have the cache values associated with it reset. Alternatively, if $type is set to 'reset' and this is -1, the entire cache will be reset.
Return value
Array of the entire cache, or NULL if the cache has been reset.
See also
5 calls to user_stats_cache_set()
- user_stats_cache_get in ./
user_stats.module - Return data from the non-persistent User Stats cache. Single values are returned according to type of statistic and unique user id.
- user_stats_get_stats in ./
user_stats.module - Returns user stats.
- user_stats_ip_address_update in ./
user_stats.module - Update the IP address of a given user.
- user_stats_login_count_update in ./
user_stats.module - Manage the login count of a given user.
- user_stats_post_count_update in ./
user_stats.module - Manage the post count of a given user.
File
- ./
user_stats.module, line 252 - User Stats provides commonly requested user statistics for themers. These are:
Code
function user_stats_cache_set($type = NULL, $uid = 0, $data = NULL) {
static $user_stats_cache = array();
// Flush entire cache.
if ($uid == -1 && $type == 'reset') {
unset($user_stats_cache);
return;
}
else {
if ($uid > -1 && $type == 'reset') {
unset($user_stats_cache[$uid]);
return;
}
}
// Set cache data. Check against NULL since a zero (in $data at least)
// is valid.
if ($type !== NULL && $data !== NULL) {
$user_stats_cache[$uid][$type] = $data;
}
return $user_stats_cache;
}