Azure 函数中的内存缓存 [英] In-memory caching in Azure function

查看:18
本文介绍了Azure 函数中的内存缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要缓存对象以提高我的 Azure 函数的性能.我尝试了 .NET ObjectCache (System.Runtime.Caching),它在我的测试中运行良好(经过长达 10 分钟的缓存保留期测试).

There is a need to cache objects to improve the perf of my Azure function. I tried .NET ObjectCache (System.Runtime.Caching) and it worked well in my testing (tested with upto 10min cache retention period).

为了推进这个解决方案,我有几个简单的问题:

In order to take this solution forward, I have few quick questions:

  1. Azure 函数的回收策略是什么.有没有默认值?可以配置吗?

  1. What is the recycling policy of Azure function. Is there any default? Can it be configured?

成本的含义是什么?

我的方法正确还是有更好的解决方案?

Is my approach right or are there any better solutions?

您可能知道的任何问题,请帮助.

Any questions that you may know, please help.

谢谢.

推荐答案

Javed,

建议使用 Redis 等进程外解决方案(或者甚至使用表存储,具体取决于工作负载).

An out-of-process solution such as Redis (or even using Table storage, depending on the workload) would be recommended.

根据经验,函数应该是无状态的,特别是如果您在动态运行时中运行,其中可能随时发生扩展操作(向上和向下)并且您的主机不能保证保持正常运行.

As a rule of thumb, functions should be stateless, particularly if you're running in the dynamic runtime, where scaling operations (up and down) could happen at any time and your host is not guaranteed to stay up.

如果您选择使用经典托管,您确实有更多的灵活性,因为您可以启用始终在线"功能,但我仍然建议您使用进程外方法.在经典模式下运行也确实会产生成本影响,因为您不再利用动态托管提供的基于消费的计费模型.

If you opt to use the classic hosting, you do have a little more flexibility, as you can enable the "always on" feature, but I'd still recommend the out-of-process approach. Running in the classic mode does have a cost implication as well, since you're no longer taking advantage of the consumption based billing model offered by the dynamic hosting.

我希望这会有所帮助!

这篇关于Azure 函数中的内存缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆