T
T
T4-1002014-10-08 22:21:07
Redis
T4-100, 2014-10-08 22:21:07

How to deal with race conditions when using redis?

I am looking for algorithms for dealing with race conditions when using redis, are there any implementation examples (preferably in php).
I clarify the question.

//некий долгий запрос
$key = md5("SELECT....");
$get_result = $redis>get($key);
if($get_result) {
    print_r($get_result);
} else {
    $query="SELECT...";
    $result = mysql_query($query);
    $row = mysql_fetch_array($result);
    $redis->set($key,$row);
    print_r($row);
}

So it turns out that if the request is long, then more and more requests will fall to the database until Redis writes the received data. How to avoid such a situation?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question