UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'dqP0+hYPmXA9JXM0TMMtlC0s+yxrjoq+IYlOB2Xm4/o=' 
WHERE 
  key_id = '8a030864adc52306df547f542e81c890d216e44e41775553edb5e65a2eee8302' 
  AND (
    token = 'dqP0+hYPmXA9JXM0TMMtlC0s+yxrjoq+IYlOB2Xm4/o=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00035