File tree 2 files changed +6
-3
lines changed
2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -766,6 +766,8 @@ openssl pkcs8 -topk8 -in client.key -out client.pk8 -outform DER -v1 PBE-SHA1-3D
766
766
the least recently used ones will be discarded.
767
767
The main aim of this setting is to prevent <classname >OutOfMemoryError</classname >.
768
768
The value of 0 disables the cache.
769
+ If a query would consume more than a half of <varname >preparedStatementCacheSizeMiB</varname >,
770
+ then it is discarded immediately.
769
771
</para >
770
772
</listitem >
771
773
</varlistentry >
Original file line number Diff line number Diff line change @@ -103,12 +103,13 @@ public Value borrow(Key key) throws SQLException
103
103
*/
104
104
public void put (Key key , Value value )
105
105
{
106
- if (maxSizeBytes == 0 || maxSizeEntries == 0 ) {
107
- // Just destroy the value if cache is disabled
106
+ long valueSize = value .getSize ();
107
+ if (maxSizeBytes == 0 || maxSizeEntries == 0 || valueSize * 2 > maxSizeBytes ) {
108
+ // Just destroy the value if cache is disabled or if entry would consume more than a half of the cache
108
109
evictValue (value );
109
110
return ;
110
111
}
111
- currentSize += value . getSize () ;
112
+ currentSize += valueSize ;
112
113
cache .put (key , value );
113
114
}
114
115
}
You can’t perform that action at this time.
0 commit comments