【发布时间】:2016-10-29 17:02:19
【问题描述】:
我正在研究 Jhipster 项目的缓存。我想在用户实体上使用缓存。
@Entity
@Table(name = "jhi_user")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class User extends AbstractAuditingEntity implements Serializable {
// attributes, getters and setters
}
我配置了ehcache.xml文件:
<cache name="com.domain.User"
timeToIdleSeconds="1800"
timeToLiveSeconds="3600">
</cache>
开发 yml 文件
spring:
devtools:
restart:
enabled: true
livereload:
enabled: false # we use gulp + BrowserSync for livereload
datasource:
url: jdbc:postgresql://localhost:xxx/cccccccc
name: ccc
username: cc
password: cc
jpa:
database-platform: com.util.PostgreSQL82Dialect
database: POSTGRESQL
show_sql: true
properties:
hibernate.cache.use_second_level_cache: true
hibernate.cache.use_query_cache: true
hibernate.generate_statistics: true
hibernate.cache.region.factory_class: org.hibernate.cache.ehcache.EhCacheRegionFactory
jhipster:
cache: # Hibernate 2nd level cache, used by CacheConfiguration
timeToLiveSeconds: 180
ehcache:
maxBytesLocalHeap: 16M
当我登录时,我的应用程序用户是从数据库中获取的。我注销并登录,用户总是从数据库中获取。 是否还有其他配置要添加? 谢谢
【问题讨论】:
标签: caching spring-data-jpa ehcache jhipster