I created an app that uses a Jason API I removed the active record from my app because the data in the API Can theoretically change and I can not erase the database every time.
Right now I have a method called self.all for each class loop through the json making rabbi object that i then call that function in different functions to work with finding data and sums and percentages I do It all works well, but seems a bit slow. I was thinking that somewhere I should have saved myself. For each column that works with the data for each column, I should call new objects instead of calling them.
... The response was provided above using HTTParty. Def self.all puppies = [] if response.success? Feedback ['puppies']. Each do Puppy Account & lt; & Lt; Glitch ['name' as puppy. All dff SUM (Pilby) # Exchanges money for money = Money.New (0, 'USD') puppies.each do | Puppy | Zodiac = puppy End of End End DEF self.prices (puppies) Prices = puppies.map {| Puppy | Puppy.price} End Diffself.names (puppies) name = puppies.map {| Puppy At the end of puppy.name} .... There are many ways in which the argument of puppy.l. in the controller ....
Should I use caching? Should I be brought back to active records? Or am I correcting that how? Should I store the puppy everywhere instead of calling the method every time?
Do I feel that whenever you call any class system, every time you Are you making a request with HTTParty? Can you imagine that for the response a class variable is creating a class variable named expires_at and then you can do some basic caching.
@@ expires_at = time.zone Now @@ http_response def make_http_call updated_http_response @@ expires_at.past? HTTP repair request for http: // upgrade_http_response # @ http_response = # HTTParty response @@ expires_at = 30.minutes.from_now End # and in your code, @@ response # changes in either response.success response? @@response.success to do?
All this is in memory and if you restart your server, then you lose everything if you want more robust caching, probably the better thing to do
No comments:
Post a Comment