• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cache which supports generics

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have used JCS in my code. But it requires me to typecast whenever i have to get any value from the cache. This is causing performance hit. So is there any other caching system available which will allow usage of generics so that typecasting is not needed?
 
author & internet detective
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anitha,
Welcome to JavaRanch!

Anitha Balasubramanian wrote: This is causing performance hit.


Really? Have you timed it? I would think a cast would be way less than repeating the thing you had cached.

Anitha Balasubramanian wrote:So is there any other caching system available which will allow usage of generics so that typecasting is not needed?


Generics still typecasts at runtime. It just avoids the need to type the typecast in code. Search for "type erasure" for more on this.
 
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are actually some cases where generics improve performance, but I can only think of a few obscure situations where that might be the case. That said, i'd prefer a cache framework with generics for the simple reason that it's likely to result in more maintainable code.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My argument is that everything is relative -- even if one operation is a few nanoseconds faster, it won't be notice if the values returned will actually be used. Meaning... if all you have is a tight loop that did nothing but call the cache code, then maybe, there is a chance you'll notice that it may be slower.

Since, in most cases, applications call the cache to fetch data, to actually do something with it, I highly doubt that there is a performance hit here.

Henry
 
R van Vliet
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:My argument is that everything is relative -- even if one operation is a few nanoseconds faster, it won't be notice if the values returned will actually be used. Meaning... if all you have is a tight loop that did nothing but call the cache code, then maybe, there is a chance you'll notice that it may be slower.

Since, in most cases, applications call the cache to fetch data, to actually do something with it, I highly doubt that there is a performance hit here.

Henry



I completely agree. I was just making the (fairly useless) observation that generics can in fact result in slightly better performance in some cases, and since we're in the "Performance" forum ;)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic