From e5cb17d0b9b33ce6959f146d3e4e3e49dd736969 Mon Sep 17 00:00:00 2001 From: Hakan Ensari Date: Tue, 10 Jan 2017 12:21:19 +0000 Subject: [PATCH] Drop caching --- .travis.yml | 2 -- Dockerfile | 2 +- Gemfile | 2 -- Gemfile.lock | 5 ----- docker-compose.yml | 4 ---- lib/api.rb | 12 +----------- spec/api_spec.rb | 11 ----------- spec/edge_cases_spec.rb | 4 ---- 8 files changed, 2 insertions(+), 40 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4df822e..2248dc0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,4 @@ before_script: - psql -c 'create database fixer_test;' -U postgres rvm: - 2.4.0 -services: - - memcached sudo: false diff --git a/Dockerfile b/Dockerfile index 34920de..d169aca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,4 +6,4 @@ ADD Gemfile /app/Gemfile ADD Gemfile.lock /app/Gemfile.lock RUN bundle install --without development test ADD . /app -CMD ./wait-for-it.sh db:5432 -s -- wait-for-it.sh memcache:11211 -s -- unicorn -c /app/config/unicorn.rb +CMD ./wait-for-it.sh db:5432 -s -- unicorn -c /app/config/unicorn.rb diff --git a/Gemfile b/Gemfile index e1f6e4d..b79ec53 100644 --- a/Gemfile +++ b/Gemfile @@ -3,12 +3,10 @@ source 'http://rubygems.org' ruby '2.4.0' -gem 'dalli' gem 'fixer' gem 'kgio' gem 'newrelic_rpm' gem 'oj' -gem 'rack-cache' gem 'rack-cors' gem 'rake' gem 'sequel_pg' diff --git a/Gemfile.lock b/Gemfile.lock index 36a5c1b..d381b59 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,7 +3,6 @@ GEM specs: ast (2.3.0) coderay (1.1.1) - dalli (2.7.6) fixer (0.7.0) kgio (2.11.0) method_source (0.8.2) @@ -21,8 +20,6 @@ GEM method_source (~> 0.8.1) slop (~> 3.4) rack (1.6.5) - rack-cache (1.6.1) - rack (>= 0.4) rack-cors (0.4.0) rack-protection (1.5.3) rack @@ -59,7 +56,6 @@ PLATFORMS ruby DEPENDENCIES - dalli fixer kgio minitest @@ -67,7 +63,6 @@ DEPENDENCIES newrelic_rpm oj pry - rack-cache rack-cors rack-test rake diff --git a/docker-compose.yml b/docker-compose.yml index ede0b57..c6b393a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,8 +2,6 @@ version: '2' services: db: image: postgres - memcache: - image: memcached web: build: . volumes: @@ -13,7 +11,5 @@ services: environment: RACK_ENV: production DATABASE_URL: postgres://postgres@db/postgres - MEMCACHE_SERVERS: memcache links: - db - - memcache diff --git a/lib/api.rb b/lib/api.rb index 4a05189..793d182 100644 --- a/lib/api.rb +++ b/lib/api.rb @@ -1,16 +1,9 @@ # frozen_string_literal: true -require 'dalli' require 'oj' require 'sinatra' -require 'rack/cache' require 'rack/cors' require 'quote' -use Rack::Cache, - verbose: true, - metastore: "memcached://#{ENV['MEMCACHE_SERVERS']}/meta", - entitystore: "memcached://#{ENV['MEMCACHE_SERVERS']}/body" - use Rack::Cors do allow do origins '*' @@ -34,14 +27,11 @@ helpers do def quote_attributes @quote_attributes ||= quote.attributes.tap do |data| + symbols = params.values_at('symbols', 'to').compact.first data[:rates].keep_if { |k, _| symbols.include?(k) } if symbols end end - def symbols - @symbols ||= params.values_at('symbols', 'to').compact.first - end - def jsonp(data) json = encode_json(data) callback = params.delete('callback') diff --git a/spec/api_spec.rb b/spec/api_spec.rb index 19da4f3..5ed2c59 100644 --- a/spec/api_spec.rb +++ b/spec/api_spec.rb @@ -10,10 +10,6 @@ describe 'the API' do let(:json) { Oj.load(last_response.body) } let(:headers) { last_response.headers } - before do - Dalli::Client.new.flush - end - it 'describes itself' do get '/' last_response.must_be :ok? @@ -101,11 +97,4 @@ describe 'the API' do get '/latest?from=GBP&to=USD&amount=100' json['rates']['USD'].must_be :>, 100 end - - it 'sets Content-Type header to JSON when caching' do - 2.times do - get '/latest' - last_response.headers['Content-Type'].must_equal 'application/json' - end - end end diff --git a/spec/edge_cases_spec.rb b/spec/edge_cases_spec.rb index bc5d792..57f0513 100644 --- a/spec/edge_cases_spec.rb +++ b/spec/edge_cases_spec.rb @@ -9,10 +9,6 @@ describe 'the API' do let(:app) { Sinatra::Application } let(:json) { Oj.load(last_response.body) } - before do - Dalli::Client.new.flush - end - it 'handles unfound pages' do get '/foo' last_response.status.must_equal 404