]> git.mxchange.org Git - friendica.git/commitdiff
Added documentation and renamed function
authorMichael <heluecht@pirati.ca>
Tue, 6 Jun 2017 17:25:28 +0000 (17:25 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 6 Jun 2017 17:25:28 +0000 (17:25 +0000)
doc/database/db_locks.md
src/Util/Lock.php

index 00556dd9538f484b0cdc417785d8eb1c3ba3bc52..004ebd1c1ed76a7db8fe961b72f4451c635b970d 100644 (file)
@@ -1,11 +1,11 @@
 Table locks
 ===========
 
-| Field   | Description      | Type         | Null | Key | Default             | Extra          |
-|---------|------------------|--------------|------|-----|---------------------|----------------|
-| id      | sequential ID    | int(11)      | NO   | PRI | NULL                | auto_increment |
-| name    |                  | varchar(128) | NO   |     |                     |                |
-| locked  |                  | tinyint(1)   | NO   |     | 0                   |                |
-| created |                  | datetime     | YES  |     | 0001-01-01 00:00:00 |                |
+| Field   | Description      | Type             | Null | Key | Default             | Extra          |
+|---------|------------------|------------------|------|-----|---------------------|----------------|
+| id      | sequential ID    | int(11)          | NO   | PRI | NULL                | auto_increment |
+| name    |                  | varchar(128)     | NO   |     |                     |                |
+| locked  |                  | tinyint(1)       | NO   |     | 0                   |                |
+| pid     |                  | int(10) unsigned | NO   |     | 0                   |                |
 
 Return to [database documentation](help/database)
index af15e106d56545a4c976976e609382bc85de93d8..ca327de1e1c80916b5af2b4082d0c2908cd09153 100644 (file)
@@ -18,30 +18,30 @@ use dbm;
  */
 class Lock {
        /**
-         * @brief Check for memcache and open a connection if configured
-         *
-         * @return object|boolean The memcache object - or "false" if not successful
-         */
-        public static function memcache() {
-                if (!function_exists('memcache_connect')) {
-                        return false;
-                }
+        * @brief Check for memcache and open a connection if configured
+        *
+        * @return object|boolean The memcache object - or "false" if not successful
+        */
+       private static function connect_memcache() {
+               if (!function_exists('memcache_connect')) {
+                       return false;
+               }
 
-                if (!Config::get('system', 'memcache')) {
-                        return false;
-                }
+               if (!Config::get('system', 'memcache')) {
+                       return false;
+               }
 
-                $memcache_host = Config::get('system', 'memcache_host', '127.0.0.1');
-                $memcache_port = Config::get('system', 'memcache_port', 11211);
+               $memcache_host = Config::get('system', 'memcache_host', '127.0.0.1');
+               $memcache_port = Config::get('system', 'memcache_port', 11211);
 
-                $memcache = new Memcache;
+               $memcache = new Memcache;
 
-                if (!$memcache->connect($memcache_host, $memcache_port)) {
-                        return false;
-                }
+               if (!$memcache->connect($memcache_host, $memcache_port)) {
+                       return false;
+               }
 
-                return $memcache;
-        }
+               return $memcache;
+       }
 
        /**
         * @brief Sets a lock for a given name
@@ -55,7 +55,7 @@ class Lock {
                $got_lock = false;
                $start = time();
 
-               $memcache = self::memcache();
+               $memcache = self::connect_memcache();
                if (is_object($memcache)) {
                        $wait_sec = 0.2;
                        $cachekey = get_app()->get_hostname().";lock:".$fn_name;
@@ -126,7 +126,7 @@ class Lock {
         * @param string $fn_name Name of the lock
         */
        public static function remove($fn_name) {
-               $memcache = self::memcache();
+               $memcache = self::connect_memcache();
                if (is_object($memcache)) {
                        $cachekey = get_app()->get_hostname().";lock:".$fn_name;
                        $lock = $memcache->get($cachekey);
@@ -147,7 +147,7 @@ class Lock {
         * @brief Removes all lock that were set by us
         */
        public static function removeAll() {
-               $memcache = self::memcache();
+               $memcache = self::connect_memcache();
                if (is_object($memcache)) {
                        // We cannot delete all cache entries, but this doesn't matter with memcache
                        return;