AppFabric localcache - appfabric

I am using AppFabric caching in one of my projects. I understand that the cache can be made available server only or it can have a local version as well (I assume this is done by instantiating the DataCacheLocalCacheProperties class and assign this to the DataCacheFactoryConfiguration's properties) - please correct me if I am wrong. I also assume that if a Get is done when a localcache is enabled, the object will be retrieved from the cache server if it is not available locally.
But, what is the case of a Put? When I have a localcache enabled, a Put that I do will update the cache server for the specified key? If yes, then how will this value be reflected in the localcache? Or, it just updates the localcache?
Thanks in advance!

Joeseph,
Yes you can use local cache to store objects in-memory at the client. Local caching is generally used to stored objects that don't change frequently. The helps with the latency costs associated with the round trip to the cache server(s).
Now coming back to your questions:-
1- You can initiate local client cache with xml configuration as well. http://msdn.microsoft.com/en-us/library/ee790880.aspx
2- When you do a Get if the cache item is not available in the local cache then it is fetched from the Cache Server(s).
3- Put always goes to the Cache Server(s).
4- Local Cache has "sync" properties that allow it to be synced with the server cache either through a) a 'timeout' value (such that once the ttl expires the object will be updated based on the server cache) or
b) Cache notifications (such that the clients are notified everytime the cache is updated on the sever) - visit http://msdn.microsoft.com/en-us/library/ee808091.aspx for more details.
HTH.
cheers,
//hr/
http://www.hammadrajjoub.net

Well AppFabrics local cache may have problems when an application updates the main cache server and if the updated items copy resides on a local cache for another application then that copy is essentially stale and needs to be evicted. I think AppFabric requires the client application to have its local cache synchronized with the main cache. This is not feasible most of the times. NCache is one of those caching products that keeps the "client" or local caches synchronized with the main cache at all times. For more information please read this:
http://www.alachisoft.com/ncache/

Related

Sitecore and Cloudflare - Personalization problem

Whenever we purge cache in Cloudflare, we somehow lose the personalization on the Sitecore SXA page. This happens regularly and also on the subpages especially (basically the parent page shows everything correctly). This happens also most of the time inside the footer page design, as it has the personalization activated for certain component inside the footer.
Does anyone knows what the issue can be? Like I said the problem happens whenever we purge the cache inside the Cloudflare.
Also, this always happens inside the en-us language culture, nowhere else.
With no more info is not so easy to understand where to fix this issue.
In your application you should try to disable cache for static assets, you will get load if under real heavy traffic then take care.
This way you will make resources not cached forcing clients to retrieve all data (css, js and so on).
When you will find the bunch of files which makes you hungry (aka the files which cause your issue) you can restore default expire headers.
You can try this if you are not on free plan (if are on free plan min TTL on edge is 2h):
Cloudflare cache rule
set edge cache TTL to 30s
set browser cache TTL to respect existing
headers
set origin cache control to ON
set performance to OFF

incr operation for a key of memcache is getting reset in every hour

I'm using memcache in gae from app engine api, it's documentation doesn't give any info for setting expiry time, but it's getting reset in every hour.
https://cloud.google.com/appengine/docs/standard/python/refdocs/google.appengine.api.memcache.html#google.appengine.api.memcache.Client.incr
from google.appengine.api import memcache
def count(key):
newVal = memcache.incr(key,delta=1,initial_value=1)
return newVal
I want the value to persist for 2 days, How can I achieve the same ?
Memcached is an in memory cache. You can never be certain that an object in cache will remain in cache.
There are many reasons why this could happen.
One your cache is full and someone tries to insert an object, memcache will evict the one that is least used
There is a concept of slabs in memcache where similar sized object are kept in one slab. It can be that your cache is not full but your slab is and that is evicting the object. You can read more about it here
One more reason could be that in newer versions of memcache (I think after 1.5.0) memcache has started to evict slabs when they are not used for a long time and a new slab requires space.
The bottom line is that you should not rely on memcached to store your data. Its best to have a source of your data as some database and use memcached as cache only.
Hope this helps

JCS: How to access cache in two different applications running in same server

jcs: I have two applications running in Glassfish. How do I retrieve cache stored in one application to another application
You could use a shared auxiliary region cache (disk, jdbc, lateral) with the same coordinates (configs).
Cache elements from application A will be available on application B when you check it or get it from shared cache.
http://commons.apache.org/proper/commons-jcs/JCSPlugins.html

how to directly access appfabric cache without proxy?

Start to learn and use appfabric cache.
From the whitepaper, http://msdn.microsoft.com/en-us/library/gg186017%28v=azure.10%29.aspx, it says:
Bulk get calls result in better network utilization.Direct cache access is much faster than proxies (ASP.NET, WCF).
I am not sure what this means. What is a proxy in appfabric world?
We do websites base on asp.net/mvc, so if we write some logic to access our abpfabric cluster, it will be called from asp.net/mvc code?
Many Thanks
If you look at the document refernced by that page it explains what is meant by caching:
In some cases, the cache client is wrapped and accessed via a proxy
with additional application or domain logic. Oftentimes, performance
of such applications is much different from the Windows Server
AppFabric Cache cluster itself. The goal of the tests in this category
is to show performance of a middle tier application with additional
logic and compare it with performance of direct access to the cache.
To accomplish the goal, a simple WCF application was implemented that
provided access to the cache and contained additional logic of
populating the cache from an external data source if the requested
object is not yet in the cache.
The document contains details on how this affected performance, but if you need more detail the source code used is available.
Using the DataCacheFactory (and/or AppFabric Session provider) from your MVC site will access the cache cluster directly, once you've granted access to the Application Pool user.

Synchronize Infinispan cache entries with database

I want to know whether I can use Infinispan for cached data synchronization with Oracle database. This is my scenario. I have two main applications. One is highly concurrent use app and the second is used as admin module. Since it is highly concurrent I want to reduce database connections (Load the entities into cache (read write enable) and use it from this place without calling database). But meantime I want to update database according to the cache changes because admin module is using database directly. Can that update process (cache to database) handle in entity level without involving application? Please let me know whether Infinispan supports this scenario or not. If supports please share ideas.
Yes, it is possible. Infinispan supports this use case.
This should be simple configuration "problem" only. All you need to use is properly configured CacheStore with passivation disabled. It will keep your cache (used by highly concurrent application) synchronized with database.
What does it exactly cause?
When passivation is disabled, whenever an element is modified, added
or removed, then that modification is persisted in the backend store
via the cache loader. There is no direct relationship between eviction
and cache loading. If you don't use eviction, what's in the persistent
store is basically a copy of what's in memory.
By memory is meant a cache here.
If you want to know even more about this and about other interesting options please see: https://docs.jboss.org/author/display/ISPN/Cache+Loaders+and+Stores#CacheLoadersandStores-cachepassivation
Maybe it's worth to consider aforementioned eviction. Whether to disable or enable it. It depends mainly on load generated by your highly concurrent application.
Actually, this only works when you use Infinispan in the same cluster for the admin module. If you load A in memory with Infinispan, change A to something else in the database directly with the admin module, then Infinispan will not know A has been updated.