UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'tEVAMF+79zipGtPkVraCcWq1MripFawX45ODDFfYRxg=' 
WHERE 
  key_id = '7f882a35eb851de6f2222b75f115a17ea46932d9e27ce9d9f205156356041eb5' 
  AND (
    token = 'tEVAMF+79zipGtPkVraCcWq1MripFawX45ODDFfYRxg=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00031