aspose file tools*
The moose likes Java in General and the fly likes java caching Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "java caching" Watch "java caching" New topic
Author

java caching

S Majumder
Ranch Hand

Joined: Jun 03, 2009
Posts: 244
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

Joined: Aug 16, 2005
Posts: 14266
    
  21

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
S Majumder
Ranch Hand

Joined: Jun 03, 2009
Posts: 244
Thanks for the reply ,
Is the PreparedStatement , resultSet internally use the caching mechanism here ?

regards,
S
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14266
    
  21

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

Joined: Jun 03, 2009
Posts: 244
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

Joined: Oct 13, 2005
Posts: 39388
    
  28
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

Joined: Jun 03, 2009
Posts: 244
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

Joined: Sep 07, 2004
Posts: 781

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.


Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39388
    
  28
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

Joined: Jun 03, 2009
Posts: 244
Thanks again ,

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

regards,
S
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

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

Joined: Jun 03, 2009
Posts: 244
James Sabre ,

It's a .csv file ...
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39388
    
  28
. . . 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

Joined: Sep 07, 2004
Posts: 781

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

Joined: Oct 27, 2005
Posts: 19718
    
  20

It's time for s begri to TellTheDetails.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java caching