UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Kh59TQaax14HUaMlXqo38k6qVLbej3a1YQek+TaW34Q=' 
WHERE 
  key_id = '674a32257ab0e7012a184765010292b802793e881c5fa8d23069e57579912013' 
  AND (
    token = 'Kh59TQaax14HUaMlXqo38k6qVLbej3a1YQek+TaW34Q=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00025