Giter Club home page Giter Club logo

redis-course's Introduction

Rails, Redis, & Postgres Case Study

In this case study we will compare Postgres with Redis scoring functions.

Goals

Learn how Redis can help improve performance of your relational database driven application.

Setup the application demo

This example uses Rails, Postgres, and Redis. Please follow the installation guide below. Setup takes 10 to 30 minutes depending on experience with the technologies.

  1. Install Homebrew

  2. Rails on El Capitan. We will be using Postgres, so you don't need to install MySQL in this guide.

  3. Follow the Homebrew Postgres instructions in the above guide to install with or download the Postgres app for MAC here. I find the Postgres app to be very useful.

  4. Install Redis with Homebrew with $ brew install redis. Then follow the prompt to start the server. Run the following to confirm things are working:

    $ redis-cli
    redis 127.0.0.1:6379> ping
    PONG
    redis 127.0.0.1:6379> set mykey somevalue
    OK
    redis 127.0.0.1:6379> get mykey
    "somevalue"
  5. Clone this application.

  6. cd into the application root run bundle install

  7. Download the example DB here. To note you can run $ rake db:seed to populate the database but it takes 20 minutes to get everything created. Downloading the tarball and using pg_restore takes abount 1 minute.

  8. Create the 'clickbait_development' database with psql or rake.

    To create the database with psql:

    $ psql
    psql (9.4.0)
    Type "help" for help.
    
    BrettU=# create database clickbait_development;
    CREATE DATABASE

    OR with rake and Rails

    $ rake db:create

  9. Restore the database with $ pg_restore -d clickbait_development clickbait_dev.tar

  10. Run $ rails server and navigate to localhost:3000. The web app should be running.

  11. In console query to confirm 365000 score cards have been created.

    $ rails c
    irb(main):001:0> ScoreCard.count
       (49.9ms)  SELECT COUNT(*) FROM "score_cards"
    => 365000
  12. Test redis in rails console:

    $ rails c
    irb(main):001:0> $redis.ping
    => "PONG"
    irb(main):002:0>
    

Congratulations on setting up the demo application. We can have a live demo when in class.

Issues? Google the exception message or open a issue in this repo.

Coming soon

An example application for the Express framework.

Links/Resources

redis-course's People

Contributors

brettu avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.