Closed fancyecommerce closed 6 years ago
redis config:
'redis' => [
'class' => 'yii\redis\Connection',
'hostname' => '127.0.0.1', // redis host
'port' => 6379, // redis port
'password' => 'xxxxxxa', // redis password
'database' => 0, // redis db
],
redis is a key-value store, finding data by other fields than the primary key is expected to be slow, there is not much one can do about that.
I made improvements to this:
public function getUuidKey($uuid, $key){
return $uuid.'###^^###'.$key;
}
$r_id = $this->getUuidKey($uuid, $key);
$one = $this->_sessionModel->find()->where([
'id' => $r_id,
])->one();
while insert data, id Assignment buy function getUuidKey($uuid, $key)
Combine 2 fields into one field for query, Perfectly solved my problem
use yii2Redis extension for Active Record, like mysql AR, find is slow
maybe, redis need a table index like mysql table index?
redis model
when is select
find is slow, use 200ms, how can is speed it? redis also need index like mysql table indexes?