mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
initial support for infinispan as 2nd level caching layer
This commit is contained in:
17
pom.xml
17
pom.xml
@@ -18,6 +18,7 @@
|
|||||||
<jpa.show_sql>false</jpa.show_sql>
|
<jpa.show_sql>false</jpa.show_sql>
|
||||||
<jpa.datasource.name>java:openejb/Resource/My DataSource</jpa.datasource.name>
|
<jpa.datasource.name>java:openejb/Resource/My DataSource</jpa.datasource.name>
|
||||||
<jpa.dialect>org.hibernate.dialect.HSQLDialect</jpa.dialect>
|
<jpa.dialect>org.hibernate.dialect.HSQLDialect</jpa.dialect>
|
||||||
|
<jpa.cache>false</jpa.cache>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
@@ -108,6 +109,16 @@
|
|||||||
<lib>org.hsqldb:hsqldb:SNAPSHOT</lib>
|
<lib>org.hsqldb:hsqldb:SNAPSHOT</lib>
|
||||||
<lib>mysql:mysql-connector-java:5.1.24</lib>
|
<lib>mysql:mysql-connector-java:5.1.24</lib>
|
||||||
<lib>postgresql:postgresql:9.1-901.jdbc4</lib>
|
<lib>postgresql:postgresql:9.1-901.jdbc4</lib>
|
||||||
|
|
||||||
|
<lib>org.infinispan:infinispan-core:5.1.4.FINAL</lib>
|
||||||
|
<lib>org.hibernate:hibernate-infinispan:4.1.11.Final</lib>
|
||||||
|
<lib>org.jgroups:jgroups:3.0.9.Final</lib>
|
||||||
|
<lib>org.jboss.marshalling:jboss-marshalling-river:1.3.11.GA</lib>
|
||||||
|
<lib>org.jboss.marshalling:jboss-marshalling:1.3.11.GA</lib>
|
||||||
|
<lib>org.codehaus.woodstox:woodstox-core-asl:4.1.1</lib>
|
||||||
|
<lib>org.codehaus.woodstox:stax2-api:3.1.1</lib>
|
||||||
|
<lib>org.rhq.helpers:rhq-pluginAnnotations:3.0.4</lib>
|
||||||
|
<lib>org.jboss.logmanager:jboss-logmanager:1.2.2.GA</lib>
|
||||||
</libs>
|
</libs>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
@@ -409,6 +420,12 @@
|
|||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
|
<profile>
|
||||||
|
<id>cache</id>
|
||||||
|
<properties>
|
||||||
|
<jpa.cache>true</jpa.cache>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
<profile>
|
<profile>
|
||||||
<id>mysql</id>
|
<id>mysql</id>
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.commafeed.backend.model;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.persistence.Cacheable;
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
@@ -12,11 +13,16 @@ import javax.persistence.Table;
|
|||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Cache;
|
||||||
|
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "FEEDS")
|
@Table(name = "FEEDS")
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
@Cacheable
|
||||||
|
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||||
public class Feed extends AbstractModel {
|
public class Feed extends AbstractModel {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.commafeed.backend.model;
|
|||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.persistence.Cacheable;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
@@ -10,11 +11,16 @@ import javax.persistence.ManyToOne;
|
|||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Cache;
|
||||||
|
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "FEEDCATEGORIES")
|
@Table(name = "FEEDCATEGORIES")
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
@Cacheable
|
||||||
|
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||||
public class FeedCategory extends AbstractModel {
|
public class FeedCategory extends AbstractModel {
|
||||||
|
|
||||||
@Column(length = 128, nullable = false)
|
@Column(length = 128, nullable = false)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.commafeed.backend.model;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.persistence.Cacheable;
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
@@ -16,11 +17,16 @@ import javax.persistence.Table;
|
|||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Cache;
|
||||||
|
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||||
|
|
||||||
import com.google.api.client.util.Sets;
|
import com.google.api.client.util.Sets;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "FEEDENTRIES")
|
@Table(name = "FEEDENTRIES")
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
@Cacheable
|
||||||
|
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||||
public class FeedEntry extends AbstractModel {
|
public class FeedEntry extends AbstractModel {
|
||||||
|
|
||||||
@Column(length = 2048, nullable = false)
|
@Column(length = 2048, nullable = false)
|
||||||
|
|||||||
@@ -1,13 +1,19 @@
|
|||||||
package com.commafeed.backend.model;
|
package com.commafeed.backend.model;
|
||||||
|
|
||||||
|
import javax.persistence.Cacheable;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Lob;
|
import javax.persistence.Lob;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Cache;
|
||||||
|
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "FEEDENTRYCONTENTS")
|
@Table(name = "FEEDENTRYCONTENTS")
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
@Cacheable
|
||||||
|
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||||
public class FeedEntryContent extends AbstractModel {
|
public class FeedEntryContent extends AbstractModel {
|
||||||
|
|
||||||
@Column(length = 2048)
|
@Column(length = 2048)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.commafeed.backend.model;
|
package com.commafeed.backend.model;
|
||||||
|
|
||||||
|
import javax.persistence.Cacheable;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
@@ -7,9 +8,14 @@ import javax.persistence.JoinColumn;
|
|||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Cache;
|
||||||
|
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "FEEDENTRYSTATUSES")
|
@Table(name = "FEEDENTRYSTATUSES")
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
@Cacheable
|
||||||
|
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||||
public class FeedEntryStatus extends AbstractModel {
|
public class FeedEntryStatus extends AbstractModel {
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.commafeed.backend.model;
|
|||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.persistence.Cacheable;
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
@@ -11,9 +12,14 @@ import javax.persistence.ManyToOne;
|
|||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Cache;
|
||||||
|
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "FEEDSUBSCRIPTIONS")
|
@Table(name = "FEEDSUBSCRIPTIONS")
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
@Cacheable
|
||||||
|
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||||
public class FeedSubscription extends AbstractModel {
|
public class FeedSubscription extends AbstractModel {
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.commafeed.backend.model;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.persistence.Cacheable;
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
@@ -12,11 +13,16 @@ import javax.persistence.Table;
|
|||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Cache;
|
||||||
|
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "USERS")
|
@Table(name = "USERS")
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
@Cacheable
|
||||||
|
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||||
public class User extends AbstractModel {
|
public class User extends AbstractModel {
|
||||||
|
|
||||||
@Column(length = 32, nullable = false, unique = true)
|
@Column(length = 32, nullable = false, unique = true)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.commafeed.backend.model;
|
package com.commafeed.backend.model;
|
||||||
|
|
||||||
|
import javax.persistence.Cacheable;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.EnumType;
|
import javax.persistence.EnumType;
|
||||||
@@ -9,9 +10,14 @@ import javax.persistence.JoinColumn;
|
|||||||
import javax.persistence.OneToOne;
|
import javax.persistence.OneToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Cache;
|
||||||
|
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "USERROLES")
|
@Table(name = "USERROLES")
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
@Cacheable
|
||||||
|
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||||
public class UserRole extends AbstractModel {
|
public class UserRole extends AbstractModel {
|
||||||
|
|
||||||
public static enum Role {
|
public static enum Role {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.commafeed.backend.model;
|
package com.commafeed.backend.model;
|
||||||
|
|
||||||
|
import javax.persistence.Cacheable;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.EnumType;
|
import javax.persistence.EnumType;
|
||||||
@@ -10,9 +11,14 @@ import javax.persistence.Lob;
|
|||||||
import javax.persistence.OneToOne;
|
import javax.persistence.OneToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Cache;
|
||||||
|
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "USERSETTINGS")
|
@Table(name = "USERSETTINGS")
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
@Cacheable
|
||||||
|
@Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
|
||||||
public class UserSettings extends AbstractModel {
|
public class UserSettings extends AbstractModel {
|
||||||
|
|
||||||
public enum ReadingMode {
|
public enum ReadingMode {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
<persistence-unit name="primary" transaction-type="JTA">
|
<persistence-unit name="primary" transaction-type="JTA">
|
||||||
<provider>org.hibernate.ejb.HibernatePersistence</provider>
|
<provider>org.hibernate.ejb.HibernatePersistence</provider>
|
||||||
<jta-data-source>${jpa.datasource.name}</jta-data-source>
|
<jta-data-source>${jpa.datasource.name}</jta-data-source>
|
||||||
|
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
|
||||||
<properties>
|
<properties>
|
||||||
|
|
||||||
<property name="format_sql" value="true" />
|
<property name="format_sql" value="true" />
|
||||||
@@ -21,6 +22,28 @@
|
|||||||
<property name="hibernate.order_updates" value="true" />
|
<property name="hibernate.order_updates" value="true" />
|
||||||
|
|
||||||
<property name="hibernate.generate_statistics" value="true" />
|
<property name="hibernate.generate_statistics" value="true" />
|
||||||
|
|
||||||
|
<property name="hibernate.cache.use_second_level_cache"
|
||||||
|
value="${jpa.cache}" />
|
||||||
|
<property name="hibernate.cache.use_query_cache" value="false" />
|
||||||
|
|
||||||
|
<property name="hibernate.cache.region.factory_class"
|
||||||
|
value="org.hibernate.cache.infinispan.InfinispanRegionFactory" />
|
||||||
|
<property name="hibernate.cache.infinispan.statistics"
|
||||||
|
value="true" />
|
||||||
|
|
||||||
|
<property name="hibernate.cache.infinispan.entity.eviction.strategy"
|
||||||
|
value="LRU" />
|
||||||
|
<property
|
||||||
|
name="hibernate.cache.infinispan.entity.eviction.wake_up_interval"
|
||||||
|
value="2000" />
|
||||||
|
<property name="hibernate.cache.infinispan.entity.eviction.max_entries"
|
||||||
|
value="100000" />
|
||||||
|
<property name="hibernate.cache.infinispan.entity.expiration.lifespan"
|
||||||
|
value="60000" />
|
||||||
|
<property name="hibernate.cache.infinispan.entity.expiration.max_idle"
|
||||||
|
value="30000" />
|
||||||
|
|
||||||
</properties>
|
</properties>
|
||||||
</persistence-unit>
|
</persistence-unit>
|
||||||
</persistence>
|
</persistence>
|
||||||
Reference in New Issue
Block a user