ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: Rodrigo Rosenfeld Rosas <rr.rosas@gmail.com>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:51999] Re: [ruby-trunk - Feature #7792] Make symbols and strings the same thing
Date: Fri, 8 Feb 2013 04:04:30 +0900	[thread overview]
Message-ID: <5113FA5E.7050104@gmail.com> (raw)
In-Reply-To: <50948DC7-BA78-452F-AAA0-BF1104FE3D8B@astro.berkeley.edu>

Em 07-02-2013 16:43, David MacMahon escreveu:
>> ...An extra parse operation on a big list could easily add 100ms to the request timing.
> So use explicit initialization instead of lazy initialization.

Sorry, didn't get. Could you please show some sample code?

>> Also, it doesn't happen only the first time but on each request.
> In the original example, JSON.parse was used on every call except the first one.  The modified example uses JSON.parse on every call including the first one.  That's why I said the modified example has only one extra JSON.parse call (i.e. the one extra one on the first call).  If that's too much overhead, either don't use lazy initialization or explicitly invoke the method once at startup to force lazy initialization so it doesn't impact the (un?)lucky first user.

I see the confusion. I simplified the code in that example. Here is how 
it would look in a real Rails controller:

class MyController

   def my_action
      @users = if cached = CacheStore.fetch('users')
        JSON.parse cached
      else
        DB[:users].select(:id, :name).all.tap{|u| CacheStore.store 
'users', JSON.unparse u}
      end
   end
end

Of course I don't cache the users list, this is just a small example. 
The real query is much more complex and could take up to a second when 
lots (20) of fields are searched using the user interface. Usually the 
query would take about 100ms or less (up to 5 fields usually) but then 
the user may want to print the results or export to Excel or changing to 
another page and caching would help a lot in that case.

  reply	other threads:[~2013-02-07 19:21 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-06 13:50 [ruby-core:51898] [ruby-trunk - Feature #7792][Open] Make symbols and strings the same thing rosenfeld (Rodrigo Rosenfeld Rosas)
2013-02-06 14:13 ` [ruby-core:51905] [ruby-trunk - Feature #7792] " trans (Thomas Sawyer)
2013-02-06 14:18 ` [ruby-core:51907] Re: [ruby-trunk - Feature #7792][Open] " Yorick Peterse
2013-02-06 14:20 ` [ruby-core:51908] [ruby-trunk - Feature #7792] " luislavena (Luis Lavena)
2013-02-06 14:22 ` [ruby-core:51910] " shyouhei (Shyouhei Urabe)
2013-02-06 14:29 ` [ruby-core:51913] " rosenfeld (Rodrigo Rosenfeld Rosas)
2013-02-06 14:33 ` [ruby-core:51914] " rosenfeld (Rodrigo Rosenfeld Rosas)
2013-02-06 14:36   ` [ruby-core:51916] " Yorick Peterse
2013-02-06 14:51     ` [ruby-core:51920] " Rodrigo Rosenfeld Rosas
2013-02-06 15:25       ` [ruby-core:51926] " Yorick Peterse
2013-02-06 17:06         ` [ruby-core:51936] " Rodrigo Rosenfeld Rosas
2013-02-06 18:22           ` [ruby-core:51940] " Yorick Peterse
2013-02-06 18:50             ` [ruby-core:51941] " Rodrigo Rosenfeld Rosas
2013-02-06 19:12               ` [ruby-core:51943] " Yorick Peterse
2013-02-06 23:45                 ` [ruby-core:51953] " Rodrigo Rosenfeld Rosas
2013-02-07  0:54                   ` [ruby-core:51956] " David MacMahon
2013-02-06 14:58 ` [ruby-core:51922] " rosenfeld (Rodrigo Rosenfeld Rosas)
2013-02-06 20:19 ` [ruby-core:51946] [ruby-trunk - Feature #7792][Rejected] " drbrain (Eric Hodel)
2013-02-06 23:01 ` [ruby-core:51951] [ruby-trunk - Feature #7792] " phluid61 (Matthew Kerwin)
2013-02-06 23:51 ` [ruby-core:51954] " rosenfeld (Rodrigo Rosenfeld Rosas)
2013-02-07  1:18 ` [ruby-core:51959] " phluid61 (Matthew Kerwin)
2013-02-07 10:46 ` [ruby-core:51972] " rosenfeld (Rodrigo Rosenfeld Rosas)
2013-02-07 12:04   ` [ruby-core:51979] " Matthew Kerwin
2013-02-07 13:09     ` [ruby-core:51981] " Rodrigo Rosenfeld Rosas
2013-02-07 21:11       ` [ruby-core:52005] " Matthew Kerwin
2013-02-07 22:17         ` [ruby-core:52008] " Rodrigo Rosenfeld Rosas
2013-02-07 23:19           ` [ruby-core:52014] " Matthew Kerwin
2013-02-07 10:50 ` [ruby-core:51973] " rosenfeld (Rodrigo Rosenfeld Rosas)
2013-02-07 11:00 ` [ruby-core:51974] " rosenfeld (Rodrigo Rosenfeld Rosas)
2013-02-07 17:34   ` [ruby-core:51994] " David MacMahon
2013-02-07 11:05 ` [ruby-core:51975] " rosenfeld (Rodrigo Rosenfeld Rosas)
2013-02-07 17:01 ` [ruby-core:51993] " jeremyevans0 (Jeremy Evans)
2013-02-07 21:15   ` [ruby-core:52006] " Matthew Kerwin
2013-02-07 22:22     ` [ruby-core:52009] " Rodrigo Rosenfeld Rosas
2013-02-07 23:58       ` [ruby-core:52016] " Yukihiro Matsumoto
2013-02-08  0:26         ` [ruby-core:52017] " Rodrigo Rosenfeld Rosas
2013-02-08  1:16           ` [ruby-core:52019] " Yukihiro Matsumoto
2013-02-08  1:57           ` [ruby-core:52021] " Bill Kelly
2013-02-08  7:07             ` [ruby-core:52030] " Rodrigo Rosenfeld Rosas
2013-02-07 18:23 ` [ruby-core:51996] " rosenfeld (Rodrigo Rosenfeld Rosas)
2013-02-07 18:43   ` [ruby-core:51997] " David MacMahon
2013-02-07 19:04     ` Rodrigo Rosenfeld Rosas [this message]
2013-02-07 19:27       ` [ruby-core:52000] " David MacMahon
2013-02-08  1:15     ` [ruby-core:52018] " Eric Hodel
2013-02-08  1:37       ` [ruby-core:52020] " David MacMahon
2013-02-09  0:50         ` [ruby-core:52055] " Eric Hodel
2013-02-12  0:02           ` [ruby-core:52135] " David MacMahon
2013-02-07 18:58 ` [ruby-core:51998] " trans (Thomas Sawyer)
2013-02-07 19:28 ` [ruby-core:52001] " rosenfeld (Rodrigo Rosenfeld Rosas)
2013-02-07 19:59 ` [ruby-core:52002] " trans (Thomas Sawyer)
2013-02-07 20:08 ` [ruby-core:52004] " rosenfeld (Rodrigo Rosenfeld Rosas)
2013-03-20 15:02 ` [ruby-core:53576] " rosenfeld (Rodrigo Rosenfeld Rosas)
2013-03-21  3:10 ` [ruby-core:53595] " Student (Nathan Zook)
2013-03-21 13:01 ` [ruby-core:53604] " rosenfeld (Rodrigo Rosenfeld Rosas)
2013-03-21 13:04 ` [ruby-core:53605] " rosenfeld (Rodrigo Rosenfeld Rosas)
2013-03-25 15:14 ` [ruby-core:53722] " Student (Nathan Zook)
2013-03-26 20:46 ` [ruby-core:53749] " alexeymuranov (Alexey Muranov)
2013-03-29 17:34 ` [ruby-core:53826] " Student (Nathan Zook)
2013-04-03 10:06 ` [ruby-core:53952] " wardrop (Tom Wardrop)
2013-04-03 13:25   ` [ruby-core:53962] " Bill Kelly
2013-04-03 10:44 ` [ruby-core:53956] " phluid61 (Matthew Kerwin)
2013-04-03 12:01 ` [ruby-core:53960] " wardrop (Tom Wardrop)
2013-04-03 22:43 ` [ruby-core:53973] " wardrop (Tom Wardrop)
2014-07-15 15:39 ` [ruby-core:63742] " andrewm.bpi
2014-08-08 20:02 ` [ruby-core:64273] " eloyesp
2017-02-16  1:22 ` [ruby-core:79546] [Ruby trunk Feature#7792] " subtileos
2017-02-16  2:21 ` [ruby-core:79548] " billk
2017-02-16  2:33 ` [ruby-core:79549] " subtileos
2017-10-05 18:19 ` [ruby-core:83130] " sheerun
2017-10-07  4:15 ` [ruby-core:83172] " shevegen
2017-12-26  8:36 ` [ruby-core:84467] " danieldasilvaferreira
2017-12-26  8:52   ` [ruby-core:84470] " Eric Wong
2017-12-26  9:12     ` [ruby-core:84474] " Daniel Ferreira
2017-12-26  9:22       ` [ruby-core:84475] " Eric Wong
2017-12-26  8:43 ` [ruby-core:84468] " danieldasilvaferreira
2017-12-26  9:24 ` [ruby-core:84477] " danieldasilvaferreira
2017-12-26 14:33 ` [ruby-core:84479] " ko1
2017-12-26 15:11 ` [ruby-core:84480] " danieldasilvaferreira
2017-12-26 15:43 ` [ruby-core:84481] " ko1
2017-12-26 19:30 ` [ruby-core:84483] " danieldasilvaferreira
2017-12-26 21:45 ` [ruby-core:84488] " merch-redmine
2017-12-26 22:11 ` [ruby-core:84489] " danieldasilvaferreira
2017-12-27 17:35 ` [ruby-core:84521] " merch-redmine
2017-12-27 19:52 ` [ruby-core:84525] " danieldasilvaferreira
2017-12-27 20:29 ` [ruby-core:84528] " andrewm.bpi
2017-12-27 20:39 ` [ruby-core:84529] " danieldasilvaferreira

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5113FA5E.7050104@gmail.com \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).