Quantcast

Ruby on Rails, Io, Lisp, JavaScript, Dynamic Languages, Prototype-based programming and more...

Technoblog reader special: $10 off web hosting by FatCow!

Friday, June 16, 2006

Caching Computations During Request Processing Even Better

In a recent post by Stefan Kaes from RailsExpress, Stefan mentions a method I have often used for speeding things up a bit.

module M
def get_data_for(request)
@cached_data_for_request ||=
begin
expensive computation depending on request returning data
end
end
end

However the problem with this method is that if get_data_for(request) returns nil, it will keep performing the request over and over again. Here is a slightly improved version if you don't always expect to get a return value.

module M
def get_data_for(request)
unless @cached_data_found
@cached_data_found = true
@cached_data_for_request =
begin
expensive computation depending on request returning data
end
end
@cached_data_for_request
end
end

You should follow me on twitter here.

Technoblog reader special: click here to get $10 off web hosting by FatCow!

23 Comments:

Anonymous Anonymous said...

longchamp handbags
coach outlet
true religion canada
oakley sunglasses
mulberry handbags
reebok shoes
burberry outlet
ralph lauren outlet
ralph lauren polo
ralph lauren
hermes belt for sale
versace sunglasses on sale
fitflops clearance
nike air max 90
thomas sabo outlet
pandora outlet
tory burch outlet
coach outlet
kobe shoes
oakley sunglasses
ghd hair straighteners
ray ban sunglasses
coach outlet online
tory burch shoes
coach outlet
ralph lauren outlet
mulberry handbags
michael kors outlet online
discount oakley sunglasses
burberry sunglasses on sale
ralph lauren pas cher
replica watches
oakley sunglasses
chrome hearts outlet online
longchamp pliage
20160531zhenhong

6:20 PM, May 30, 2016

 
Anonymous Anonymous said...

toms outlet
michael kors online
ralph lauren uk
coach factory outlet
tory burch outlet
replica watches
toms shoes
fitflops sale
coach outlet
michael kors factory outlet
oakley sunglasses wholesale
longchamp handbags
air max 90
michael kors handbags wholesale
louis vuitton sunglasses
michael kors outlet online
louis vuitton bags
oakley sunglasses
ray ban sunglasses
fitflops clearance
chaussure louboutin
swarovski crystal
michael kors outlet store
michael kors outlet sale
chrome hearts outlet
louboutin pas cher
coach outlet online
louis vuitton outlet
louis vuitton neverfull sale
ralph lauren outlet
rolex watches
swarovski outlet
nike huarache
oakley sunglasses
ralph lauren outlet
20160531zhenhong

6:22 PM, May 30, 2016

 
Blogger Hua Cai said...

true religion jeans
snapbacks wholesale
michael kors outlet
nike air max 90
juicy couture outlet
ugg boots
air max 2015
fred perry polo
ralph lauren uk
nike roshe run
air max 90
fitflop sale
ugg outlet
nike roshe run shoes
nike roshe run
nike air max
oakley sunglasses
true religion jeans
longchamp handbags
tiffany jewellery
ugg outlet
cheap nfl jerseys
air max 90
nike outlet online
cheap soccer jerseys
nike air force 1
tory burch outlet online
rolex watches
tiffany jewelry
coach outlet online
chicago blackhawks jerseys
louis vuitton handbags outlet
lululemon outlet
reebok trainers
michael kors outlet
20160804caihuali

10:41 PM, August 03, 2016

 
Blogger Fangyaya said...

abercrombie and fitch
tod's shoes
ugg boots uk
jordan 13
michael kors handbags
ugg outlet
uggs uk
toms shoes
uggs
michael kors outlet
canada goose jackets
coach outlet store online clearances
michael kors outlet clearance
louis vuitton outlet
canada goose outlet
michael kors handbags
oakley vault
louis vuitton handbags
ugg boots
michael kors outlet
the north face jackets
gucci outlet
louis vuitton outlet
louis vuitton outlet stores
michael kors handbags
celine handbags
christian louboutin outlet
true religion outlet
adidas nmd
chenyingying20160908

6:56 PM, September 07, 2016

 
Blogger John said...

ugg outlet
burberry bags
cheap ugg boots
cheap oakley sunglasses
ugg pas cher
polo ralph lauren outlet online
ysl handbags
oakley sunglasses outlet
ed hardy outlet
michael kors outlet canada
2016927yuanyuan

6:23 PM, September 26, 2016

 
Blogger chenlina said...

adidas yeezy 350
ugg boots
adidas trainers
mbt shoes
cheap jordan shoes
gucci outlet
louis vuitton
washington wizards jerseys
ugg australia
coach factory outlet
chenlina20161018

7:50 PM, October 17, 2016

 
Blogger Denature said...

Menghilangkan Kutil Di KemaluanSebagai penambahan, diduga hal yang menjadi penyebab munculnya kutil pada uretra pria adalah karena rasa nyeri yang terjadi pada saat buang air kecil. Saat ini juga sudah banyak obat dan perawatan yang dapat dipilih penderita, namun tidak semua dari obat dan perawatan itu dapat efektif menyembuhkan secara total. untuk cara pemesanana silahkan kunjungsitus kami

obat tradisional wasir eksternalWasir adalah pembuluh darah teriritasi dan meradang terletak di anus, sedangkan kanker disebabkan oleh sel-sel yang berkembang biak di luar kendali. untuk cara pemesanana silahkan kunjungartikel selanjutnya

obat kelamin pria keluar nanahPerbedaan yang kedua terletak pada cairan nanah yang dikeluarkan saat buang air kecil. Pasien gonore atau kencing nanah akan mengeluarkan cairan nanah ketika mereka buang air kecil, sedangkan pasien sipilis atau raja singa tidak mengalami hal ini. untuk cara pemesanana silahkan kunjungartikel selanjutnya

obat ambeien yang alami

1:45 PM, November 16, 2016

 
Blogger Unknown said...

ray ban sunglasses
air max 90
michael kors handbags
fitflops shoes
reebok outlet
saics running shoes
ed hardy
seahawks jersey
yeezy boost 350
ecco shoes

12:29 AM, March 16, 2017

 
Blogger shengda xu said...

moncler jackets
birkenstock shoes
fitflop
michael kors outlet online
fake rolex watches
mlb jerseys
discount oakley sunglasses
ray ban glasses
air max 90
nike flyknit
xushengda0418

6:44 AM, April 18, 2017

 
Blogger shengda xu said...

pandora soldes
yeezy boost
yeezy shoes
mulberry bags
clarks shoes outlet
coach factory outlet online
toms outlet
cheap rolex replica watches
nike sneakers
coach factory outlet online
xushengda0714

2:45 AM, July 14, 2017

 
Blogger Quang Đào Duy said...

Chung cư Green Pearl nằm trong quần thể Dự án Green Pearl tại số 378 Minh Khai, Vĩnh Tuy, Hai Bà Trưng, Hà Nội là một vị trí đắc địa thuộc cửa ngõ phía Nam của Thủ đô, tiếp giáp với đường Minh và KĐT times city. Căn hộ chung cư cao cấp Green Pearl sẽ mở ra không gian sống xanh, trong lành, KHÔNG ồn ào, KHÔNG khói bụi ngay trong lòng đô thị.
Chung cư Green Pearl

7:13 AM, August 27, 2017

 
Anonymous Obat Tradisional Disfagia (Sulit Menelan) said...

Articles that are very interesting to read, hopefully provide benefits for many people

Obat Sembuhkan Sesak Nafas
Pengobatan Tuntaskan Penyakit Kudis
Bahaya Dan Cara Mengobati Ginjal Bocor
Pengobatan Atasi Dislokasi Sendi
Pengobatan Alternatif Untuk Mengangkat Miom
Pengobatan Untuk Menyembuhkan Tukak Lambung

12:12 AM, March 12, 2018

 
Blogger Sarah Betty said...

Me gustó el artículo completo ... de primera clase escrita, gracias por toda la información que le han proporcionado. para que salga de comentarios significativos del blog es necesario leer, aprehender y examinar el envío del blog.
Se sabe que los juegos Friv son una posición segura donde las personas pueden buscar las mejores actividades que se realicen de forma gratuita. Aquí está la página friv actividades se puede ver que el sitio incluye muy poco texto y el sitio web está compuesto por docenas de pequeñas fotos que pueden vincular a los participantes con el juego que desean jugar.

1:02 PM, March 22, 2018

 
Anonymous cara mengobati benjolan di kelopak mata said...


I can only express a word of thanks. Because with the content on this blog I can add knowledge I, thank has been sharing this information. Do not forget to visit our website to share information and knowledge about health.
obat benjolan di kelopak mata
cara pemesanan QnC Jelly Gamat
cara mengobati usus kotor

6:56 PM, May 17, 2018

 
Anonymous Cara menyembuhkan impetigo said...

may be useful for all, helpful article once and pardon me permission to share also here :

Obat penyakit scabies
Obat herbal usus buntu
Obat tradisional gagal jantung
Obat lambung bengkak
Cara mengatasi sakit ulu hati
Cara menyembuhkan cacar air
Obat tulang retak

7:26 PM, June 04, 2018

 
Blogger Rino Febri said...

I can only express a word of thanks. Because with the content on this blog I can add knowledge I, thank has been sharing this information. Do not forget to visit our website to share information and knowledge about health.
obat penurun asam lambung paling ampuh
obat oles penyakit dompo
cara mengobati kanker payudara
cara mengobati penyakit gudik

11:29 PM, June 04, 2018

 
Blogger Rino Febri said...

I can only express a word of thanks. Because with the content on this blog I can add knowledge I, thank has been sharing this information. Do not forget to visit our website to share information and knowledge about health.
vitamin penambah nafsu makan anak
agen herbal QnC jelly Gamat kota kudus
Cara Mengatasi Rematik palindromic
herbal penghancur batu empedu
obat rorombehen paling manjur
cara menghancurkan batu empedu
obat budug paling ampuh

12:30 AM, June 23, 2018

 
Blogger shinta agustian said...

Hopefully, sustenance will be easy and simplified in all matters :-)
KHASIAT JELLY GAMAT GOLD-G
Cara Mengobati Panu Kadas Kurap
obat gondok alami
khasiat dan kegunaan walatra habbaza
khasiat walatra habbaza softgel

5:41 PM, August 29, 2018

 
Blogger 5689 said...

zzzzz2018.9.2
christian louboutin sale
off white shoes
pandora outlet
ugg boots clearance
canada goose outlet
canada goose jackets
moncler outlet
christian louboutin outlet
soccer boots
christian louboutin shoes

6:22 PM, September 01, 2018

 
Blogger 洛噷 said...

2018906 leilei3915
ugg boots outlet
louboutin shoes
coach outlet
polo ralph lauren
michael kors outlet online
pandora jewelry
coach factory outlet
ray ban sunglasses
fitflops sale
uggs outlet

12:02 AM, September 06, 2018

 
Blogger icha charisa said...

The post is written in very a good manner and it contains many useful information for me. Thank you very useful information admin, and pardon me permission to share articles here may help :

obat benjolan di bawah rahang
obat amandel bengkak
obat benjolan di ketiak
obat tumor ginjal
obat lambung bocor
obat borok di kepala

1:45 AM, September 12, 2018

 
Blogger Rani Anggraeni said...

The post is written in very a good manner and it contains many useful information for me. Thank you very useful information admin, and pardon me permission to share articles here may help :

obat benjolan di bawah rahang
obat amandel bengkak
obat benjolan di ketiak
obat tumor ginjal
obat lambung bocor
obat borok di kepala

11:46 PM, September 12, 2018

 
Blogger risa icha said...

This is such a great resource that you are providing and you give it away for free. I love seeing websites that understand the value of providing a quality resource for free. It is the old what goes around comes around routine

risa herbal
penyebab sakit pinggang
obat penyakit mata glaukoma
obat gagal ginjal
obat penebalan dinding rahim
obat penghancur kanker
obat varikokel

1:17 AM, September 18, 2018

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home

 

If you like this blog, you might also like top photography schools.