Bee V1.11一级缓存对实体Javabean的要求
在Bee 1.11之前的版本, 缓存是采用类似单例模式的,多次获取的缓存对象是共享内存空间的,虽然比较快,但在修改某次获取的缓存时, 会影响到其它查询获取的结果.
从V1.11开始, 采用原型模式, 每次查询都会获取一份全新的结果集. 使用此,需要Javabean实现序列化,否则默认情况是不放缓存的.
V1.11提供了三种模式.
#prototype: 0 not prototype, but faster; 1:prototype,if have NotSerializableException, do not put in cache, slower, but safer; 2 : prototype, but have NotSerializableException,return original
#high safe cache,the javabean(entity) need implements Serializable interface.
bee.osql.cache.prototype的值,可以是0,1,2
bee.osql.cache.prototype=0 #单例模式, 兼容之前的版本
bee.osql.cache.prototype=1 #原型模式 较安全, 若实体Javabean没有实现Serializable接口,则不放缓存. (V1.11默认使用)
bee.osql.cache.prototype=2 # 先采用原型模式,当实体Javabean没有实现Serializable接口,将采用之前的单例模式