Server One variable multiple users can be modified at the same time, how to implement?
For example: I set the variable $ A,
Multiple members, called $ A, are the same object, not separate. But it cannot be implemented with a database.
$a = 100;
When Zhang San, visit $ A and change $ A to 5;
At this point, John Doe access $ A, see $ A $5, John Doe change $ A to 50,
Multiple users can modify $ A and more can be seen. Similar to shared variables.
How is it implemented?
------Solution--------------------
Public variable class PHP code based on Memcache
Class Tshare { private static $_instance; Private $memcache; Private Function __construct () { $this->memcache = new Memcache; $this->memcache->connect (' 127.0.0.1 ', 11211) or Die ("Could not Connect"); } public static function getinstance () { if (empty (self::$_instance)) self::$_instance = new self (); return self::$_instance; } function __set ($name, $val) { $this->memcache->set ($name, $val, false, +); } function __get ($name) { return $this->memcache->get ($name);