Re: Application-level variables

16 views
Skip to first unread message

Daniel Doubrovkine

unread,
May 7, 2013, 2:03:25 PM5/7/13
to ruby-...@googlegroups.com
API-level caching is much more complicated than just server-side caching. You want to support requests with If-Modified-Since and If-None-Match, etc. 

Check out this video of a talk I gave at GoRuCo last year, it's exactly on this topic: http://confreaks.com/videos/986-goruco2012-from-zero-to-api-cache-w-grape-mongodb-in-10-minutes


On Mon, May 6, 2013 at 8:44 AM, Евгений Куртов <m...@lessless.pp.ua> wrote:
Hello! I want to cache my data and not to hit remote services with each client request. As I understand I need something like this

module Acme
  class App
    attr_accessor :cached

    def initialize
      @cached = SomeService.fetch('unique-key')
    end

    def call(env)
      puts env.class
      response = Pease::API.call(env)
    end
  end
  
  class API < Grape::API
    format :json

    get :ping do
      Acme::App.cached
    end
  end
end

How do I do this? In general  I would like to create a separate class that will take care of all data that can be demanded by the client and consumed via API. 

--
You received this message because you are subscribed to the Google Groups "Grape Framework Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-grape+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--

dB. | Moscow - Geneva - Seattle - New York
dblock.org - @dblockdotorg

Reply all
Reply to author
Forward
0 new messages