Giriş
Şu satırı dahil ederiz. İkinci seviye ön bellek içindir.
Şöyle yaparız.
Şu satırı dahil ederiz. İkinci seviye ön bellek içindir.
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
Şu değerleri alabilir
- ReadOnlyCache
- ReadWriteCache
- NonstrictReadWriteCache
- TransactionalCache
Açıklaması şöyle
Read-onlyUseful for data that is read frequently but never updated (e.g. referential data like Countries). It is simple. It has the best performances of all (obviously).Read/writeDesirable if your data needs to be updated. But it doesn't provide a SERIALIZABLE isolation level, phantom reads can occur (you may see at the end of a transaction something that wasn't there at the start). It has more overhead than read-only.Nonstrict read/writeAlternatively, if it's unlikely two separate transaction threads could update the same object, you may use the nonstrict–read–write strategy. It has less overhead than read-write. This one is useful for data that are rarely updated.TransactionalIf you need a fully transactional cache. Only suitable in a JTA environment.
NONSTRICT_READ_WRITE
ÖrnekŞöyle yaparız.
@Entity
@Table(...)
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class MyAnswer implements Serializable {
...
}
Hiç yorum yok:
Yorum Gönder