UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = '6PnXcIyhwnmPWrIf9qkeTzEcNEJO/Nnamouv3Oj+Tc0=' 
WHERE 
  key_id = '790da5424ea65b152c685f65f8999405fc6de36f482fb0933a0a69097afa6310' 
  AND (
    token = '6PnXcIyhwnmPWrIf9qkeTzEcNEJO/Nnamouv3Oj+Tc0=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00037