UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'cDnemgppsna83xoDnuq41mjYIHj3tryI3LxN+vMSKuE=' 
WHERE 
  key_id = '4fe9b0f05356e3afbeb2fbfd23946998db99e7d4033fe47acf70e248f041f806' 
  AND (
    token = 'cDnemgppsna83xoDnuq41mjYIHj3tryI3LxN+vMSKuE=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00026