function updatecreditcache($uid, $type, $return = 0)
{
    $all = countcredit($uid, $type);
    $halfyear = countcredit($uid, $type, 180);
    $thismonth = countcredit($uid, $type, 30);
    $thisweek = countcredit($uid, $type, 7);
    $before = array('good' => $all['good'] - $halfyear['good'], 'soso' => $all['soso'] - $halfyear['soso'], 'bad' => $all['bad'] - $halfyear['bad'], 'total' => $all['total'] - $halfyear['total']);
    $data = array('all' => $all, 'before' => $before, 'halfyear' => $halfyear, 'thismonth' => $thismonth, 'thisweek' => $thisweek);
    C::t('forum_spacecache')->insert(array('uid' => $uid, 'variable' => $type, 'value' => serialize($data), 'expiration' => getexpiration()), false, true);
    if ($return) {
        return $data;
    }
}
function updatecreditcache($uid, $type, $return = 0)
{
    $all = countcredit($uid, $type);
    $halfyear = countcredit($uid, $type, 180);
    $thismonth = countcredit($uid, $type, 30);
    $thisweek = countcredit($uid, $type, 7);
    $before = array('good' => $all['good'] - $halfyear['good'], 'soso' => $all['soso'] - $halfyear['soso'], 'bad' => $all['bad'] - $halfyear['bad'], 'total' => $all['total'] - $halfyear['total']);
    $data = array('all' => $all, 'before' => $before, 'halfyear' => $halfyear, 'thismonth' => $thismonth, 'thisweek' => $thisweek);
    DB::query("REPLACE INTO " . DB::table('forum_spacecache') . " (uid, variable, value, expiration) VALUES ('{$uid}', '{$type}', '" . addslashes(serialize($data)) . "', '" . getexpiration() . "')");
    if ($return) {
        return $data;
    }
}