JPA和Memcached有何不同?

编程入门 行业动态 更新时间:2024-10-26 22:18:30
本文介绍了JPA和Memcached有何不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试找出Memcached和JPA之间的区别,这就是我从所掌握的信息中得出的结论

I am trying to figure out the difference between Memcached and JPA, this is what I infer from the information I have

  • Memcached:在内存中缓存数据和对象,就像动态数据库一样,以快速访问数据.该层刚好在实际的数据库之上(比如说我的sql).它具有自己的列和行,您可以在其中保存一些临时数据(热数据).小型数据库,位于RAM中.

  • Memcached: Cache data and objects in memory, like an on the fly database to quickly access the data. This layer is just above the actual db (say my sql). It has its own columns and rows, where can you keep some temporary data (hot data). A small database, in RAM.

    JPA:管理关系数据(应存储在数据库中的数据),开发该数据可简化生活,即,我们不必进入休眠状态. (对于外行的说法,我对JPA感到困惑,我对此感到困惑)

    JPA: manage relational data (data which should go in database), developed to make life easy, i.e. we don't have to go into hibernate and stuff. (I am a lil confused about JPA in layman's term :| )

    所以,从我看到的地方开始:

    So, from where I see":

  • 两者都提供了将关系数据保存在内存中的功能. -错误
  • 用于快速访问数据.-错误
  • 两者都是相同的(我肯定不是)-错误
  • Both give feature to save relational data in the memory. - WRONG
  • Used to make data access quick.- WRONG
  • Both are same (which I am sure are not)- WRONG
  • 现在,有人告诉我他们在系统中使用了Memcahed和JPA(它们处理庞大的数据集),那有什么意义呢?

    Now, some one told me that they used Memcahed and JPA in their system (they deal with huge datasets) So, how does that make sense?

    添加的问题:阅读答案后,如果我要开发一个处理海量数据集的系统,我将使用memcached,但我仍然不明白,为什么我应该选择JPA如果:1.我需要处理大量数据,2.使系统具有可伸缩性.

    ADDED Question: After reading the answers, if I am making a system which deals with huge datasets, I will go with memcached, but I still don't understand, why should I go for JPA if: 1. I need to deal with huge data sets, 2. Make system scalable.

    推荐答案

    JPA是一种ORM(对象关系映射器),用于将对象模型映射到关系数据库模型.

    JPA is an ORM (object-relational mapper) to map an object model to a relational database model.

    Memcache是​​一个内存中的缓存,只不过是一个键-值对映射.

    Memcache is an in-memory cache that is little more than a key-value pair map.

    它们确实适用于不同的应用程序. JPA是使用SQL的替代方法.它具有缓存元素,但是主要数据源是数据库,因此持久性数据也是如此. Memcache数据生活在内存中,并且不是持久性的,因此对于更多的瞬态数据而言.

    They're really for different applications. JPA is an alternative to using SQL. It has caching elements but the primary data source is a database so is for presistent data. Memcache data lives in memory and isn't persistent so is for more transient data.

    让我补充一个可能引起争议的点: JPA无法扩展.

    Let me add another possibly controversial point: JPA doesn't scale.

    JPA(和所有ORM)是一种便利,可以通过将对象模型投影到关系数据库上来加快开发速度,但是它不如本机SQL快.通常,您最终将无法确定生成高性能SQL的设置的正确组合.正如乔尔所说,所有抽象都是泄漏的. JPA也不例外.

    JPA (and all ORMs) are a convenience that can speed up development by projecting an object model onto a relational database but it's not as fast as native SQL. Often you'll end up figuring ou tthe right combination of settings that generates performant SQL. As Joel says, all abstractions are leaky. JPA is no exception.

    让我强调一点,您可以在使用JPA方面走得相当远,但是在某些时候,您将需要使用SQL.

    Let me stress that you can go reasonably far with JPA but at some point you will need to go to SQL.

    Memcache解决了一个不同的问题,不应与JPA进行真正的比较.但是,只要您可以对数据进行分区,Memcache的扩展性就非常好,在这种情况下,您可以拥有所需数量的服务器,而瓶颈将成为网络带宽,内存和CPU.

    Memcache solves a different problem and shouldn't really be compared with JPA. Memcache scales extremely well however as long as you can partition your data, in which case you can have as many servers as you need and the bottleneck becomes network bandwidth, memory and CPU.

    更多推荐

    JPA和Memcached有何不同?

    本文发布于:2023-11-22 08:36:21,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1616715.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:有何不同   JPA   Memcached

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!