| 
					
				 | 
			
			
				@@ -381,24 +381,13 @@ func (r *Registry) FindDeviceById(args uint64, reply *models.Device) error { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return err 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	cache := getCache() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	key := fmt.Sprintf("Device:%v", args) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if v, ok := cache.Get(key);ok { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		device := v.(*models.Device) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		setDevice(reply, device) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		d := &models.Device{} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		d.ID = uint(args) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		err = db.Where(d).First(reply).Error 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			return err 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		var storage models.Device 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		storage = *reply 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		cache.Set(key, &storage) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	d := &models.Device{} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	d.ID = uint(args) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	err = db.Where(d).First(reply).Error 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if err != nil { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return err 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	return nil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -410,7 +399,7 @@ func (r *Registry) FindDeviceByRecordId(args *rpcs.ArgsDeviceAuth, reply *models 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	cache := getCache() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	key := fmt.Sprintf("Device:%v", args.DeviceID) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-	if v, ok := cache.Get(key);ok { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	if v, ok := cache.Get(key); ok { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		device := v.(*models.Device) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		setDevice(reply, device) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} else { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -425,12 +414,9 @@ func (r *Registry) FindDeviceByRecordId(args *rpcs.ArgsDeviceAuth, reply *models 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		cache.Set(key, &storage) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	return nil 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // ValidateDevice will validate a device key and return the model if success. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 func (r *Registry) ValidateDevice(key string, device *models.Device) error { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	id, err := r.keygen.DecodeIDFromRandomKey(key) 
			 |