CrumpledDog / Umbraco-AzureCDNToolkit

Makes it easy to fully utilise the Azure CDN with a Umbraco website
13 stars 14 forks source link

Added RedisCache #10

Closed gfyans closed 4 years ago

gfyans commented 6 years ago

I've added the ability to use a Redis cache instead of the default local cache. The idea is to move away from having multiple caches (if you are running more than 1 instance i.e. scaled out) and to stop the app from clearing the cache when a change is detected to the config or assemblies.

I've tested this on my environment and it seems to work, and I've added some tests for the RedisCache class.

It's set up to fall back to local cache if for whatever reason it can't connect to the Redis Cache by just checking for a config setting. This seemed like a good option without doing any architectural changes to the solution (to interface the Cache and inject whichever one you want to use).

Jeavon commented 6 years ago

Wow, this is awesome, it has always been on my list to add optional Redis support.

I'll have a good look and test soon

webmonger commented 6 years ago

@Jeavon Hey, The team at Screenmedia are actively developing this, is there any way we can help support an maintain this package with you?

Cheers Jon

Jeavon commented 6 years ago

@webmonger I love the PR, and it's implemented exactly how I planned. I've just not had the time to test it, so it's fantastic you have done so! One question I had was if the dashboard needed some modification when Redis was in use....

Jeavon commented 6 years ago

@webmonger Also it would be great to add you to this repo if you are willing to help with support and maintenance!

webmonger commented 6 years ago

@Jeavon Let me have a chat with the team here and work out who best to add to the repo.

I'm not sure about the dashboard @dconlisk is this something you could have a look at when you do the next internal review?

webmonger commented 6 years ago
dconlisk commented 6 years ago

Yeah @webmonger can do :)

webmonger commented 5 years ago

@Jeavon Hey, I just wanted to open this discussion up again. Any chance you could add me so I can manage this at our end? I would like to make sure this is working for v8 too so being able to manage PRs would be helpful. Cheers

Jeavon commented 5 years ago

@webmonger yes of course

webmonger commented 5 years ago

Got it, cheers. I'll get this PR merged in and have a look at whats required for V8 in the week hopefully.

c9mb commented 4 years ago

Was this ever pulled into the project, or did it just end up as a private branch?

I was contemplating trying to implement some form of persistent storage into this project using PetaPoco to try and eliminate the excruciating url discovery delays when the url cache needs to be remapped after every restart - just initialize the cache from the stored copy then update the stored copy (hopefully async) every time the cache is updated.

I know nothing about RedisCache and whether or not it requires an external service (I do know that such services are offered commercially) but perhaps this is what I should be exploring instead?

webmonger commented 4 years ago

Merged, sorry for the very long delay.

Yes Redis is a very fast cache thats easy to implement. Give this a try and see how it works out.

c9mb commented 4 years ago

Many thanks for that.

As mentioned, I have no experience with RedisCache, but I presume this PR provides a client to an external service that needs to be provided?

My intended for use for this is with Umbraco-Cloud, so I would assume that means using an external provider such as Azure or AWS? I note that "Azure Cache for Redis" is definitely not cheap, particularly given that MS discourage the use of their 'basic' tier for production sites.

Do you have any experience with RedisCache providers that you can recommend?

webmonger commented 4 years ago

We normally use the base redis cache on azure. Never had a problem. It can be used for a lot of other things once it’s there too so worth reading up.

Not sure how it works with cloud as I’ve no experience with that.

c9mb commented 4 years ago

Cheers - I'll try that then. Cloud shouldn't complicate anything in that regards, it should just be another external Azure service, same as Blob-Storage and CDN. I was more alluding to not being able to self-host a local RedisCache server, if that was a requirement.

c9mb commented 4 years ago

Should this be installable via package manager as Our.Umbraco.AzureCDNToolkit 0.2.0-alpha-000075 ?

I've tried installing package Our.Umbraco.AzureCDNToolkit 0.2.0-alpha-000075 but no luck.

I note that it has a dependency of Our.Umbraco.AzureCDNToolkit.Core >= 0.2.0-alpha-000050 which is what gets installed if starting fresh, and the latest version of Our.Umbraco.AzureCDNToolkit.Core is 0.2.0-alpha-000062, so whether either installing or upgrading the package, the binary doesn't get updated to the latest version.

The commit also seems to suggest a dependency on StackExchange.Redis.1.2.6 but this is not installed via the package - I assume that I need to install this separately myself? Is that the only additional requirement?

c9mb commented 4 years ago

Sorry to be a nuisance, but should Our.Umbraco.AzureCDNToolkit.Core have been updated to 0.2.0-alpha-000075 to make these updates installable by package-manager. At the moment only Our.Umbraco.AzureCDNToolkit has been updated, which just handles the config and plugin, not the binary and its dependencies.

c9mb commented 3 years ago

Hi @gfyans @webmonger - firstly, many apologies for dragging up such and old thread, terribly rude of me I know - but I'm getting pressure from a client with a large image-based site to solve the latency problems we are experiencing with Umbraco-Cloud and AzureBlobStorage, and running out of ideas.

I need to try and get the RedisCache option working for this package, to see if that will solve the cache-url lookup delays when using the default LocalCache option, as this is killing the startup and page-load times of this large site.

I am testing on a small site and have installed AzureCDNToolkit-0.2.0-alpha-000076 and StackExchange.Redis-1.2.6 (and also CodeShare.TLS1.2.Umbraco just for good measure) and have a Base Azure-RedisCache config running, with the connectionstring added in the appropriate place of Web.Config

However, the metrics panel on Azure is showing no keys and no gets, which makes me think the site is not using Redis and is falling back to Local, and when I try a restart of the site and check the cached URLs in the AzureCDNToolkit dashboard, it always shows as empty until I start to get page access and it rebuilds.

I've tried dropping the TLS level to 1.0 and even tried using non-SSL access, but to no avail.

I'm not sure if I'm missing something, or doing something wrong, and not even sure how to tell if it's working or not, because of the fallback.

I'd really appreciate any help or pointers on where to look and diagnose this, as my boss is getting a bit 'testy'.

c9mb commented 3 years ago

Solved - RedisCode missing from NG packages - only available in the repo.