Forráskód Böngészése

Se añade método para utilizar hset

Maxi Schvindt 7 éve
szülő
commit
eeee6a1760
2 módosított fájl, 25 hozzáadás és 0 törlés
  1. 1 0
      Services/CollectorInterface.php
  2. 24 0
      Services/RedisService.php

+ 1 - 0
Services/CollectorInterface.php

@@ -11,4 +11,5 @@ interface CollectorInterface
     public function set($key, $data);
     
     public function setString($key, $data);
+    
 }

+ 24 - 0
Services/RedisService.php

@@ -120,4 +120,28 @@ class RedisService extends Redis implements CollectorInterface
         
     }
 
+    /**
+     * @param string $key
+     * @param string $field
+     * @param array $data
+     */
+    public function hset($key, $field, $data, $output = false)
+    {
+        $start = microtime(true);
+        $_save = json_encode($data);
+        $end = microtime(true);
+        $t = $end - $start;
+        if ($output) {
+            print_r("ENCODE key '{$key}.{$field}': {$t} segundos" . PHP_EOL);
+        }
+
+        $start = microtime(true);
+        parent::hset($key, $field, $_save);
+        $end = microtime(true);
+        $t = $end - $start;
+        if ($output) {
+            print_r("SETEX key '{$key}.{$field}': {$t} segundos" . PHP_EOL);
+        }
+    }
+
 }