UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'D9haEnyO/4Gcbn7qzMflJvFuXs5tfYXAFYbT3Oeu46M=' 
WHERE 
  key_id = '87c74c64515904c13b38a5bf3d76c6446ec3eabec25854597d98344c69520e01' 
  AND (
    token = 'D9haEnyO/4Gcbn7qzMflJvFuXs5tfYXAFYbT3Oeu46M=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00034