简体   繁体   English

为每个 session 的一级缓存分配 memory

[英]Allocating memory for first level cache per a session

When some of sessions fetch many entities, these entities are stored in the first-level cache and this can lead to out of memory problems and server crash.当某些会话获取许多实体时,这些实体存储在一级缓存中,这可能导致 memory 问题和服务器崩溃。

This may happen for many different reasons, like a developer writing a bug in his query, or allowing setting of incorrect parameters on the screen.这可能由于许多不同的原因而发生,例如开发人员在他的查询中写了一个错误,或者允许在屏幕上设置不正确的参数。

The problem I intend to target is NOT to resolve the problem on a single application level, but rather to prevent the server crash.我打算针对的问题不是解决单个应用程序级别的问题,而是防止服务器崩溃。 It is perfectly fine if the application operation will fail.如果应用程序操作失败,那很好。

Is there a way to prevent Hibernate from allocating entities per a session after reaching some maximum?有没有办法防止 Hibernate 在达到某个最大值后根据 session 分配实体?

You could maybe try to use a Hibernate Interceptor to maintain a counter per session and throw an exception if it exceeds a threshold, but there is no builtin way of doing what you want.您也许可以尝试使用 Hibernate Interceptor来维护每个 session 的计数器,如果超过阈值则抛出异常,但没有内置的方式来做你想做的事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM