$m = new Memcached();
$res = $m->get("key");
if(empty($res)) {
$ret = $m->set("key");
$ret && $this->insert($data);
}
Why does the insert data repeat in the above code? What is the correct way to write it?
$m = new Memcached();
$res = $m->get("key");
if(empty($res)) {
$ret = $m->set("key");
$ret && $this->insert($data);
}
Why does the insert data repeat in the above code? What is the correct way to write it?
does anyone know how to solve it? Wait on the line! Currently, there are the following abnormal data
solve this problem with mem locks
there is obviously something wrong with the logic of your code
$ret & & $this- > insert ($data);
ret is empty.
MC is not persistent either. It can only be intercepted at the first level. To prevent repetition, it still depends on the unique index of the database
if there is too much concurrency, you can consider using locks, and $ret & $this- > insert ($data);) in your logic. Without a rigorous judgment, that is, when concurrency is realized, as long as $ret is implemented, it will result in repeated insertion of $this- > insert, and at the same time limit duplicate values in combination with the unique index of the database
.A large binary tree with uncertain tree hierarchy. Now we need to realize the following requirements: 1. Record hierarchical relationships. For example: to give you a node id:9, needs to find out the son or grandson under this node, or. Or all descenda...