I am using JCS for caching purposes and I am experiencing an issue where the data is not written to a disk,i.e no error is coming,but when I look at the data files,they are all 0k in size.Anybody know what is causing this error,I am using the properties file provided in the JCS web site.
-
Do you know its an error? Perhaps it only writes to disk when the cache is over some limit. i.e. it only writes when it has to. – Peter Lawrey Dec 05 '11 at 13:03
-
No error is being shown in the log,and files are being created,but the thing is it shows file size as 0kb,and also I tried printing out the metadata,which also shows that no files are present in the disk cache i.e the disk cache is empty – Madusudanan Dec 05 '11 at 13:08
-
Thumbs up..I checked the configuration and cleared the issue.Thanks for the help.Wish I could award points to you. – Madusudanan Dec 05 '11 at 13:10
-
Ok, added my comment as an answer. – Peter Lawrey Dec 05 '11 at 13:20
2 Answers
One of the cacheattributes is DiskUsagePatternName. The value can either be SWAP or UPDATE. SWAP is the default. UPDATE writes the cache data to disk right away.
In your cache.ccf add a line for
jcs.region.[yourregionid].cacheattributes.DiskUsagePatternName=UPDATE
That way it will write to disk without needing to shutdown the cache and you can still get the benefits of the memory cache.
The disk cache only writes the data when the cache object is disposed. In a web application I had to explicily call dispose() in the destroy() method of my servlet. If you don't call dispose() and don't have have the disk usage pattern set to UPDATE it won't write to disk.

- 31
- 2
Do you know its an error? Perhaps it only writes to disk when the cache is over some limit. i.e. it only writes when it has to.
Using Madhu's solution: When jcs.default.cacheattributes.MaxObjects=0
the file size will always be 0. Remove this and you can see data in the files.

- 525,659
- 79
- 751
- 1,130
-
Done.Keep helping people while you can,it really saves lot of time and effort.Believe me,I searched for half an hour on the net and did not find a solution,but now the solution is really simple.Anyway thanks for the help. – Madusudanan Dec 05 '11 at 13:22
-
-
1Well its nothing,I just set the jcs.default.cacheattributes.MaxObjects=0 Previously it was having some value,we intend to ignore some simple things while developing. – Madusudanan Dec 05 '11 at 13:26