Rails如何在保存到数据库时快速呈现页面?

时间:2015-08-11 19:43:33

标签: ruby-on-rails ruby-on-rails-4

需要:

  1. 将某些参数保存到数据库,如请求参考。
  2. 超快速渲染响应。
  3. 控制器示例:

    ---
    - name: Base-AMI | Create a Base-AMI
      hosts: localhost
      connection: local
      gather_facts: False
      vars_files:
          - vars.yml
      tasks:
    - name: Launch instance
      ec2:
         key_name: "{{ key_pair }}"
         group: "{{ security_group }}"
         instance_type: "{{ instance_type }}"
         image: "{{ image }}"
         wait: true
         region: "{{ region }}"
         vpc_subnet_id: "{{ vpc_subnet_id }}"
         assign_public_ip: yes
         instance_tags:
           Type: Base-AMI
      register: ec2
    
    - name: Add new instance to host group
      add_host: hostname={{ item.public_ip }} groupname=launched ansible_ssh_user=ubuntu ansible_ssh_private_key_file=~/.ssh/{{ key_pair }}.pem
      with_items: ec2.instances
    
    - name: Wait for SSH to come up
      wait_for: host={{ item.public_dns_name }} port=22 delay=60 timeout=320 state=started
      with_items: ec2.instances
    
    - name: Configure instance(s)
      hosts: launched
      sudo: True
      gather_facts: True
      roles:
        - common
        - rubyserver
    
    - name: Base-AMI | AMI Creation
      hosts: localhost
      connection: local
      gather_facts: False
      tasks:
    
    - name: Launch instance
      ec2_ami:
        instance_id: "{{ item.id }}"
        wait: yes
        name: Base-AMI
        tags:
          Date: "{{ ansible_date_time.iso8601 }}"
        device_mapping:
            - device_name: /dev/sda1
              size: 10
              delete_on_termination: true
              volume_type: gp2
      register: instance
    

    当用户请求此操作时,它不会超快,因为它首先需要写入数据库。

    以后可以写入数据库吗?

    我曾尝试设置后台作业但速度也很慢。存储此信息的最快方法是什么?在文件中?

0 个答案:

没有答案