Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java caching

 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everybody,
Please explain me what is java caching and where we can implement it ?

Thanks and regards,
S
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15436
41
Android IntelliJ IDE Java Scala Spring
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The word cache is a common term that can mean many different things in different contexts. The general idea is that it's a small but quickly accessible place where data can be stored, so that data that is retrieved frequently can be accessed quickly.

For example, a database uses some of the RAM of a computer to cache part of the content of the database. The data in the cache can be accessed much more quickly than the data that's on disk.

Webservers store pages that are accessed often in a cache in RAM so that those pages don't have to be loaded from disk each time they are accessed.

A CPU has a small amount of very fast memory on the CPU itself, in which it caches data that is frequently used by the running application.

There is no common thing called "java caching". Ofcourse you can implement caches in Java, but how you would do that depends on what exactly you want to cache and for what purpose.
 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply ,
Is the PreparedStatement , resultSet internally use the caching mechanism here ?

regards,
S
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15436
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you do a database query using a PreparedStatement and you read out the results from a ResultSet, then undoubtedly there will be some cache involved somewhere. The database will most likely hold all (or part) of the results in memory until you're done with them (by calling close() on the ResultSet). But it's really up to the implementation of the database and JDBC driver that you are using what it caches exactly and how (in other words, it's impossible to say in general how that cache would work in detail).
 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks again .

I have one problem ,,

I have two huge files (each around 4GB ) & those files contains some random numbers .I want to take only common numbers and put into a 3rd file . I have no provision to increase the JVM size , how can I do this?


regards,
S
 
Campbell Ritchie
Sheriff
Pie
Posts: 49733
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does "only common" mean?
Can you read the numbers individually? If you can deal with the numbers individually and discard them after use, the memory will be cleared for re-use.
 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Campbell Ritchie , you are write ,
I am doing the code that way , but the problem is , it is taking huge volatile memory to run .
Do you have any suggestion ?


 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
s begri wrote:
Do you have any suggestion ?


Read one file and place all the 'numbers' in a table in a database. Read the second file and check whether or not each number is in the database table. If it is then add it to another table.

This will required very little RAM.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49733
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean you cn't deal with the numbers individually. So James Sabre's suggestion sounds the best so far. It is a lot easier to help (or to know we don't know what to do) if you give us fuller details.
 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks again ,

Can I read a huge datafile part by part and compare with the second file ?

regards,
S
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
s begri wrote:Thanks again ,

Can I read a huge datafile part by part and compare with the second file ?

regards,
S


Possibly - but the Devil is in the detail but you have not given any. What do the files look like? What are you trying to compare?
 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James Sabre ,

It's a .csv file ...
 
Campbell Ritchie
Sheriff
Pie
Posts: 49733
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and what sort of numbers does it contain? How many are duplicated? Describe the problem, otherwise nobody will know what to suggest.
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
s begri wrote:James Sabre ,

It's a .csv file ...


This is like getting blood out of a stone. I don't understand the OP's reluctance to give any details that might allow people to help him to decide how to process the files and I can't be bothered to keep pestering him for the details.

Bye
 
Rob Spoor
Sheriff
Pie
Posts: 20605
60
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's time for s begri to TellTheDetails.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic