This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of React Cookbook: Recipes for Mastering the React Framework and have David Griffiths & Dawn Griffiths on-line!
See this thread for details.
Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

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: 40722
827
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: 23906
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 ;)
 
Clowns were never meant to be THAT big! We must destroy it with this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic