azure cache on localhost - c#

I'm developing an application to run in azure.
I'm making use of the azure cache, however when I run this locally I don't want to connect up to Azure to use the cache because it's a bit slow and tedious.
Can you run the cache locally?
[EDIT]
This is .Net C#

Unfortunately, you do need to connect to azure to test the windows azure cache service. Read this for more info: http://msdn.microsoft.com/en-us/library/windowsazure/gg278342.aspx

You can use Windows Server AppFabric Cache when local debug. It utilizes very similar configuration and program mode, which means almost all you need to change is the cache server IP and access token.
But I'd better to create a separated Cache layer to isolate the cache operations. For example introduces ICache interface with Add, Get, Remove, etc. methods. Then you can implement the Azure Cache, Memcached, In-Proc Cache, etc. in vary cases.
There's a good cache layer you might be interested in, check the ServiceStack project at GitHUB https://github.com/ServiceStack/ServiceStack/tree/master/src/ServiceStack.Interfaces/CacheAccess

It's not possible. To use the windows azure caching service locally, you'll always have to route your request to azure, which adds a serious delay on top of the request.
To property test your cache, you need to deploy your service in azure.
As others said, you can use Windows Server AppFabric caching locally, but be warned, there are some differences between the Windows Server AppFabric caching and the Windows Azure caching service, like for example the notifcation based invalidation on local cache items is not supported in azure. Make sure not to use any of these features while developing locally, or you might get surprised when deploying your service to the cloud.
Only the timeout based invalidation on local cache is supported for the windows azure caching service. Windows azure caching service is designed to be used for your cloud services, so it makes sense it's kinda crappy when using with on on-premise application.

Azure AppFabric caching uses a subset of the functionality of Windows Server AppFabric caching. If you're willing to setup a server in house with the cache installed you could probably get something comparable to using the Azure cache. I haven't tried this myself, so while I know that the code you'd need to write is more or less the same between the two, I'm not sure how different the configs need to be.
Chances are though that it's going to be a lot less time and effort to just use the Azure cache.

This article specifically talks about what you are trying to do. Create a caching "infrastructure" that switches between local and distributed cache based on configuration(s):
http://msdn.microsoft.com/en-us/magazine/hh708748.aspx

Now you can use azure in-role cache and try locally using emulator

Related

How to use Azure App Service Local Cache?

I am having a MVC API project which is using a server side cache. It is deployed to Azure App Service. I was wondering to make use of App Service Local Cache to overcome challenge of keeping the cache in sync across nodes.Is this the right approach ? If yes, how do i modify the cache from my code.
PS: I am not much interested in using the Redis Cache.
I was wondering to make use of App Service Local Cache to overcome challenge of keeping the cache in sync across nodes.
What does sync across nodes mean? Do multiple webapp applications share cache data?
HttpRuntime.Cache can only be used in a single webapp application and cannot be accessed by other webapps. Once each cache is created, it takes up server resources. So from this point we can say: it is not that the more cache, the better. The cache has a time limit. After the expiration time set by the server, it will be recycled by the server. The cache can store any object.
So if you want to share cache data across sites, it is impossible to achieve, which is why the redis cache appears.
If you really don't want to use redis cache, then you can store the required data in sql server. This can only be an alternative, not the best.

Alternative SignalR Redis implementation within Load Balancer Environment

We have completed a hybrid mobile application that makes use of SignalR (.Net Core) on the backend.
The issue we have now discovered is that, SignalR does not play nicely with load balancers and although there is Azure and Redis, to get this approved will be a nightmare.
Does anyone know of any alternative solution we can deploy without having to go to the architecture forum for approval of Redis.
Ideally, within C# WebApi and deploy to IIS.
NOTE! We cannot make use of Redis or Azure in our case.
Quick update: going to test this solution tomorrow. If we are successful, I will post an official answer.
https://dotnet.myget.org/feed/aspnetcore-master/package/nuget/Microsoft.AspNetCore.SignalR.SqlServer

Azure Redis Cache development

I am trying to implement Azure Redis Cache in my app. When I see the documents they say I have to define a cache storage in the Azure online tool. I am wondering is there a way to skip that step and use Redis for development without using the actual server thing?
You can install Redis locally and use localhost. That might be one of your options even though I don't think it's faster.
You can download it and install it from here.
You can run Redis server locally, and start the experiment. But if you have decided to use Azure Redis, you should develop toward the real one as early as possible. Several reasons:
Azure Redis supports SSL and this is the default port. You should use this.
Azure Redis has high availability support through master slave.
Azure Redis provide Cluster support.
It might experience unexpected patching process causing temporarily data loss
These things are not easily setup and test locally.

SharePoint 2010 and ASP.net Cache

We have a web farm of 4 SharePoint 2010 server. As web1, web2, web3, web4 and its AAM is http://xxx.sharepoint.com. Now I am making a web part where some data is going to be cached by HttpContext.Current.Cache. Now as we know that ASP.NET cache is limited to server memory and it is not shared between other servers in the web farm, So I created a solution where I will go to each server and in web.config I will fill the server list in the farm with semicolon separated and whenever any thing add to the cache I will send data to the other server and sync the cache and do the same for cache items removed.
Now my problem is how I will call other server individually by its own name in the SharePoint farm.
For example (http://web1/)
Not a direct answer but you can use timer jobs on Sharepoint for implementing something on all servers. Note that Sharepoint timer service must be running on all servers and it does not happen real-time(it doesn't take long either).
I used memcache, which is working good :) as expected
Microsoft Velocity is perfect use case for your scenario. Velocity will provide you distributed and in-memory cache.
Link:
Build Better Data-Driven Apps With Distributed Caching

MongoDB on Azure: replSet can't get local.system.replset config

I am using the MongoDB worker role project to use MongoDB on Azure. I have two separate cloud services, in one of them everything works fine, however in the other, the MongoDB worker role is stuck in a Busy (Waiting for role to start... Calling OnRoleStart state.
I connected to one of the MongoDB worker roles and accessed the MongoDB log file and found the following error:
[rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
There are threads on how to fix this normally, but not with Windows Azure. I did not configure anything for the MongoDB worker role (apart from Azure storage connection strings), and it works in another service, so I don't know why it isn't working for this service. Any idea?
Some time ago I was trying to host RavenDB in Azure as Worker Role and had lot's of issues with it as well.
Today, I believe it's better to run database the "suggested" way on target platform which is as Windows Service according to this "Install MongoDB on Windows" guide. This way you won't have to deal with Azure-specific issues. To achieve this you can:
Use Azure CmdLets along with CsPack.exe to create the package for MondoDB.
A solution similiar to RavenDB Master-Slave reads on Azure which I posted on GitHub.
Sign up for Virtual Machine (beta) on Azure, kick off a machine and install MongoDB manually there.
But I guess the most important question when hosting DB is: where do you plan to store the actual DB?
Azure's CloudDrive, which is a VHD stored in Cloud Storage, has the worst IO performance possible. Not sufficient for normal DB usage I'd say.
Ephemeral storage, a Cloud Service local disk space, has perfect IO, but you lose all data once VM is deleted. This means you usually want to make continious or at least regular backups to Cloud Storage, maybe through CloudDrive.
Azure VM attached disk - has better IO than CloudDrive, but still not as good as Ephemeral storage.
As for the actual troubleshooting to your problem. I'd suggest wrapping OnRoleStart with try-catch, writting it to the log, enabling RDP to the box and then connecting and looking into the actual issue right in place. Another alternative is using IntelliTrace, but you need VS Ultimate for that. Also, don't forget that Azure requires usage of Local Resources if your app needs to make writes to the disk.

Categories