Browse Source

:bug: info()参数错

visuddhinanda 3 years ago
parent
commit
93e0c26315
1 changed files with 44 additions and 21 deletions
  1. 44 21
      app/Console/Commands/TestRedis.php

+ 44 - 21
app/Console/Commands/TestRedis.php

@@ -39,41 +39,64 @@ class TestRedis extends Command
      */
     public function handle()
     {
-		$this->info("test redis");
-		Redis::set("test-redis",'this is a test');
-		$this->info("redis get:".Redis::get("test-redis"));
+		$value='this is a test';
+		$this->info("test redis start");
+		Redis::set("test-redis",$value);
+		if(Redis::get("test-redis")==$value){
+			$this->info("redis set ok ");
+		}else{
+			$this->error("redis set fail ");
+		}
+		
+
+		Redis::hSet("test-redis-hash",'hash',$value);
+		if(Redis::hGet("test-redis-hash",'hash')==$value){
+			$this->info("redis hash set ok ");
+		}else{
+			$this->error("redis hash set fail ");
+		}
 
-		Redis::hSet("test-redis-hash",'hash','this is a test hash');
-		$this->info("redis hash get:".Redis::hGet("test-redis-hash",'hash'));
 
-		$this->info("test cache");
-		$this->info("cache put key=cache-key value=cache-value");
-		Cache::put('cache-key','cache-value',1000);
-		if(Cache::has('cache-key')){
-			$this->info('cache get: ',Cache::get('cache-key'));
+		$this->info("test cache start");
+		$this->info("testing cache put");
+		$key = 'cache-key';
+		Cache::put($key,$value,1000);
+		if(Cache::has($key)){
+			$this->info("cache::put() exist key={$key}");
+			if(Cache::get($key)==$value){
+				$this->info("cache::get() ok value={$value}");
+			}else{
+				$this->error("cache::get() fail ");
+			}
 		}else{
 			$this->error('no key cache-key');
 		}
-		$this->info("test cache() function");
-		$this->info("cache() key=cache-key-2 value=cache-value-2");
-		cache(["cache-key-2"=>'cache-value-2']);
-		if(Cache::has('cache-key-2')){
-			$this->info('cache() get: ',Cache::get('cache-key-2'));
+
+
+		$key = 'cache-key-2';
+		$this->info("testing cache() function");
+		$this->info("cache() key={$key} value={$value}");
+		cache(["cache-key-2"=>$value]);
+		if(Cache::has($key)){
+			if(Cache::get($key)==$value){
+				$this->info("cache() get ok value={$value}");
+			}else{
+				$this->error("cache::get() fail ");
+			}
 		}else{
 			$this->error('no key cache-key-2');
 		}
 
-		$this->info("test cache remember()");
-		$value = Cache::remember('cache-key-3',600,function(){
+		$key = 'cache-key-3';
+		$this->info("testing cache remember()");
+		$value = Cache::remember($key,600,function(){
 			return 'cache-value-3';
 		});
-		if(Cache::has('cache-key-3')){
-			$this->info("cache-key-3 exist value=",Cache::get('cache-key-3'));
+		if(Cache::has($key)){
+			$this->info("{$key} exist value=".Cache::get($key));
 		}else{
 			$this->error("cache::remember() fail.");
 		}
-
-
         return 0;
     }
 }