How to get programmatically the maxBytesLocalHeap for a specific cache? - ehcache

I am configuring my caches from an ehcache.xml file, among other configurations I set there the maxBytesLocalHeap for all the caches.
I also have a web interface where I have to show all the available caches, their actual size and their maximum size.
I am able to get the global maxBytesLocalHeap but I can not find a way to get this for each cache. Is there any method to do this? (Or an workaround if is not possible to get it via Ehcache public APIs)
PS: My caches are using only on-heap memory.

#Flowryn..you can get the each & every detail about each Cache using StatisticsGateway Class...Use
cache.getStatistics().getLocalHeapSizeInBytes()
I addition to above there are many Methods which u can use to show on your web interface...
Let me know if you need any clarification on it.

Related

Reading from and Writing to a centralized cache using Talend

I want to implement caching in Talend. By this I mean that I want to read from and write to cache memory through Talend. The cache memory will be a centralized one. I read about tHashInput/Output which are used to read from and write to cache memory.
My questions are:
Are there any other components apart from tHashInput/Output to read/write to cache?
In tHashOutput we have a drop down menu named Data Write Model. What is its significance? I ask this because I have a scenario where I would be using a centralized cache memory where many people would be reading from and writing to cache. In that case what other options drop down menu can have?
tHashOutput/Input are the best components for cache . You can also use tBufferOutput/Input but you won't be able to put more than 1 tBufferOutput for each job.
I don't think there are other options in this dropdown menu.
For each job, the cache used by tHash components is only usable within this execution of a job. You won't be able to recover it during another run.
If you are using webservices (as providing a SOAP method for a webservice with talend for example), tHashOutput is not very reliable : from time to time the cache will be accessible, but not always.
You Could check one of my previous questions about this :
Building a cache with Talend SOAP webservices

How to limit memory/item size in a named cache in windows app fabric cache?

I am relatively new to .net / windows technologies and I need to use appfabric cache for a project.
After spending some time, I feel that one of the basic functionalities of a cache framework, namely limiting the size of a cache, is absent in the appfabric caching framework. I know that popular java caching frameworks like ehcache and hazelcast has this functionality through xml configuration elements (maxElementsInMemory attribute in ehcache , max-size attribute in hazelcast).
I know that this question has been asked previously in a similar form:
How to set Windows Server AppFabric named cache size?
However, I could not find a conclusive proposal to limit cache size per named cache basis in app fabric.
I need to expose caching apis to several application development groups. Each group is supposed to be assigned their own named cache but I need a mechanism to prevent cache abuse. Each cache user should live with their own limited named cache space. I.e they should not consume more memory than the amount reserved for them.
I do not want to write ugly custom code in my api to limit this and I believe that this is a basic requirement that a caching framework should support.
Any proposal for how to achieve this in app fabric will highly be appreciated.
Thanks

Monitoring JCS Cache Usage

Our application is using JCS for caching frequently used data.
I wanted to know if JCS maintains(or can generate) any statistics having information like cache usage, cache misses, etc?
We recently decided to parallelise some job using multithreading. Although the threads will be working on different data, but they would be sharing the same cache (this I figured as they would be running in same JVM, and the JCS cache is a singleton class, please correct me if I am missing something here..).
So I need to analyse if we need to change the cache configuration for the added load.
Thanks a for your help!
The following web site gives a detail introduction,scroll down to the bottom of the page
Click here
If u want everything in a single go then use compCache.getStatistics(),refer to the API documentation for more information.
There is a JSP available that shows you some of the information you are looking for like cache hits, misses, total memory used, etc. You may have to edit it a little to fit into your project, but it's handy.
http://svn.apache.org/repos/asf/commons/proper/jcs/trunk/src/java/org/apache/jcs/admin/JCSAdmin.jsp

Doctrine 2 Caching Workflow

I am new to caching
What should I cache
eg. Do I cache user info? eg. since they are frequently used throughout the application (like in the header saying "welcome {username}")?
But most things should be used quite frequently anyways? eg. Users have projects. These projects don't belong to everyone, but they will be frequently used by specific users do I cache them too? Won't I be caching nearly everything then?
Also regarding CRUD, with doctrine queries, I can just use $query->useResultCache(true) but what happens when I update/delete an entity? I need to somehow update my cache too? how?
The basic principle of caching is to hold frequently used data that doesnt change often in memory to reduce database work.
Its more convenient to use the php session variables to hold basic things like username.
In case of projects, if they dont change often, and retrieved by users frequently, it would be a good idea to cache them. How long a project info stays cached depends on the change frequency.
Also note that if the info you present to users is vital or time important, you should use caching cautiously.
Check this reference page for basic information on caching http://www.doctrine-project.org/docs/orm/2.0/en/reference/dql-doctrine-query-language.html#cache-related-api
Or check http://www.doctrine-project.org/docs/orm/2.0/en/reference/caching.html for detailed explanation.

disable Enterprise Library Caching Application Block

We're using the Enterprise Library Caching Application Block to do caching (in memory) in our web service. Works great, no complaints.
We're starting to do some load testing, and I've been asked to disable the cache so we can get some relative idea of what kind of performance gain caching gives us. I thought this would be simple - it turns out its not.
I can't find any configuration setting to disable the cache. I suppose I could turn down the maximumElementsInCacheBeforeScavenging setting, but is there a better way?
I found one post that suggests creating your own Cache Manager that does nothing - again, is there a better way to do this?
Your best bet is to provide a custom implementation of ICacheManager (interface added in Entlib 4, can't help for earlier ones) that doesn't store anything and never gives a cache hit. Then you configure the block to use your "NullCacheManager" or whatever you want to call it.

Resources