亚音速,支持缓存

发布于 2024-07-26 15:55:49 字数 451 浏览 3 评论 0原文

制定一个具有以下要求的项目。

  • 数据读取密集型应用程序。
  • 一次最大并发用户数为 100。 应用程序具有非常高的流量
  • 虽然数据很大,但每天只修改一次

决定使用亚音速,因为易于开发并且有在高流量环境中工作的潜力。

虽然还没有找到/解决一些问题来与 SubSonic 3 一起使用,但是

  • 哪种类型的层可以使用 Active Records、Repository、Linq To SQL
  • 来处理分页/排序存储过程(因为在显示 10000 时,它们会比内置分页机制提供更好的性能) + 行分页和排序对吗?)
  • 缓存,根据项目需求,很明显,需要大量使用缓存。 但找不到适合亚音速的解决方案。 我是否必须为其创建单独的层,如果是,一个简短的示例会有所帮助。

Having a project with following requirements in mind.

  • data reading intensive application.
  • 100 max concurrent users a times. Application have very high traffic
  • Though data is huge it is getting modified only once a day

Decided to use subsonic cause of ease of development and potential to work in high traffic environment.

Though few things are not yet found/solved to work with SubSonic 3

  • Which type of layer to use Active Records, Repository, Linq To SQL
  • working with paging / sorting stored procedures (cause they will give better performance over inbuilt paging mechanism, when displaying 10000+ rows with paging and sorting. right?? )
  • Caching, with project requirement it is quite clear, heavy use of caching is required. But could not find suitable solution, which will work with subsonic.
    do I have to create separate layer for it and if yes, a short example would be helpful.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

北陌 2024-08-02 15:55:49

我为 subsonic 2.x ActiveRecord 编写了一个 CacheUtil 类。 它基于某人在旧亚音速论坛上发布的一些代码。 (这是来自在删除最后一个论坛之前删除的论坛。这就是软件论坛应该是永久的原因。)以下是缓存查找方法的示例。 您可以将其调整为 ss3。 还有inserts、fetchall、delete、clear等。Rob Connery当时说缓存有问题,故意被排除在ss2之外。 通过使用 HttpRuntime.Cache,我同时在 Web 应用程序和服务之间共享缓存。 我相信我可以做到这一点,因为它是一个小型应用程序,始终位于单个服务器上。

public static RecordBase<T> Find<T, ListType>(object primaryKeyValue)
    where T: RecordBase<T>, new()
    where ListType: AbstractList<T, ListType>, new()
{
    string key = typeof(T).ToString();
    if(HttpRuntime.Cache[key] == null)
        FetchAll<T, ListType>();
    if(HttpRuntime.Cache[key] != null)
    {
        ListType collection = (ListType)HttpRuntime.Cache[key];
        foreach(T item in collection)
        {
            if(item.GetPrimaryKeyValue().Equals(primaryKeyValue))
                return item;
        }
    }
    return null;
}

I wrote a CacheUtil class for subsonic 2.x ActiveRecord. It's based on some code someone posted on the old subsonic forums. (This is from a forum that was deleted before the last forum was removed. This is why software forums should be permanent.) Here is an example of a cache Find method. You could adapt it to ss3. There are also inserts, fetchall, delete, clear, etc. Rob Connery said at the time that caching was problematic, and it was left out of ss2 on purpose. By using HttpRuntime.Cache I share the cache between a web application and service simultaneously. I believe I can do this since it's a small application, always on a single server.

public static RecordBase<T> Find<T, ListType>(object primaryKeyValue)
    where T: RecordBase<T>, new()
    where ListType: AbstractList<T, ListType>, new()
{
    string key = typeof(T).ToString();
    if(HttpRuntime.Cache[key] == null)
        FetchAll<T, ListType>();
    if(HttpRuntime.Cache[key] != null)
    {
        ListType collection = (ListType)HttpRuntime.Cache[key];
        foreach(T item in collection)
        {
            if(item.GetPrimaryKeyValue().Equals(primaryKeyValue))
                return item;
        }
    }
    return null;
}
陌若浮生 2024-08-02 15:55:49

写了一篇关于我如何在 SubSonic 2.x 中使用缓存。 它与 3.x 并非 100% 兼容,但概念是相同的。

I wrote a post about how I used caching with SubSonic 2.x. It isn't 100% compatible with 3.x but the concepts are the same.

满意归宿 2024-08-02 15:55:49

I answered this similarly over here Thread-safe cache libraries for .NET. Basically you need a CollectionCacheManager - I then add a layer on top for each type and funnel all requests through this individual cache controllers, which in turn are using the 1 collectioncachecontroller. At the outer layer I mix pure subsonic, linq, whatever fits the bill at the time. That's the beauty of SubSonic is that it should not get in your way. As far as stored proc performance I would point to Jeff Atwoods articles over at CodingHorror and reevaulaute your savings. Hardware is dirt cheap, as is memory, databases are not. Personally I keep the database super simple and lightweight, and prefer to let my webserver cache everything in memory. The database server gets to do very little work which is the way I like it. Adding a few extra load balanced web servers isn't nearly as big of a deal as increasing database throughput, clustering, or sharding a a DB. SQL & Stored Procs can also be ridiculously difficult to write, and maintain. Take that budget that you would have spent on your time doing that, and instead beef up your hardware... Remember hardware is dirt cheap, good developers are not. Good luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文