dever 6 년 전
부모
커밋
064230a08e
1개의 변경된 파일27개의 추가작업 그리고 9개의 파일을 삭제
  1. 27 9
      main/src/Content.php

+ 27 - 9
main/src/Content.php

@@ -137,27 +137,45 @@ class Content extends Core
         return 'ok';
     }
 
-    public function testcache()
+    public function test_redis()
     {
         # 测试缓存
         $redis = new \Redis;
 
+        $expire = 3600;
+
+        $key = 'test_';
+
+        $redis->connect('192.168.0.220', '6379');
+
+        for($i=0; $i<= 100;$i++) {
+            $redis->set($key . $i, 'key_' . $i . '_value_' . rand(0,10000), $expire);
+        }
+
+        for($i=0; $i<= 100;$i++) {
+            $data[] = $redis->get($key . $i);
+        }
+
+        print_r($data);die;
+    }
 
+    public function test_memcache()
+    {
+        # 测试缓存
+        $cache = new \Memcached;
 
         $expire = 3600;
 
         $key = 'test_';
 
-        for($i=0; $i<= 10000;$i++) {
-            $redis->connect('server-redis', '6379');
-            $redis->auth('dm_redis_123');
-            $redis->set($key . $i, $i, $expire);
+        $cache->addServer('192.168.0.220', '11211', 100);
+
+        for($i=0; $i<= 100;$i++) {
+            $cache->set($key . $i, 'key_' . $i . '_value_' . rand(0,10000), $expire);
         }
 
-        for($i=0; $i<= 10000;$i++) {
-            $redis->connect('server-redis', '6379');
-            $redis->auth('dm_redis_123');
-            $data[] = $redis->get($key . $i);
+        for($i=0; $i<= 100;$i++) {
+            $data[] = $cache->get($key . $i);
         }
 
         print_r($data);die;