Redis版本
我後台的程式設定了會員ID的起始數
<?php
$redis->set('userId',intval($start));
?>
前台的會員註冊會取得這個userId,然後當做它的ID
<?php
$userId = $redis->get('userId');
if($model->insert(['userId'=>$userId])){
$redis->incr('userId');
}
但現在的問題是,我無論怎麼註冊會員,這個redis中的userId都不會變,在伺服器上操作
incr userId
會回傳錯誤「(error) ERR value is not an integer or out of range」
get userId
"i:10003;"
求大神,沒用過幾次redis,有些蒙
我猜想你初始化程式碼的時候用了
所以到資料庫的最終值是一個字串
"i:10003;"
,而字串就不能 incr 了如果你一定要使用序列化,只能將就使用 zIncrBy,zIncrBy 被序列化的是 member,操作的是 score,所以不會受到影響
我這個是可以的,你按照我的試試。
"i:10003;"
設定的userId根本不是數字啊