Merge pull request #2041 from apemost/fix-readme

Improve syntax highlighting
pull/2085/head
Nikita Koksharov 6 years ago committed by GitHub
commit 6e517726ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,19 +1,18 @@
Redis based Hibernate Cache implementation # Redis based Hibernate Cache implementation
===
Implements [Hibernate 2nd level Cache](https://docs.jboss.org/hibernate/orm/5.4/userguide/html_single/Hibernate_User_Guide.html#caching) provider based on Redis. Implements [Hibernate 2nd level Cache](https://docs.jboss.org/hibernate/orm/5.4/userguide/html_single/Hibernate_User_Guide.html#caching) provider based on Redis.
Supports all Hibernate cache strategies: `READ_ONLY`, `NONSTRICT_READ_WRITE`, `READ_WRITE` and `TRANSACTIONAL`. Supports all Hibernate cache strategies: `READ_ONLY`, `NONSTRICT_READ_WRITE`, `READ_WRITE` and `TRANSACTIONAL`.
It's recommended to use FST or Snappy as [codec](https://github.com/redisson/redisson/wiki/4.-data-serialization). It's recommended to use FST or Snappy as [codec](https://github.com/redisson/redisson/wiki/4.-data-serialization).
Compatible with Hibernate 4.x, 5.x. (5.3.0, 5.3.1 and 5.3.2 versions aren't supported) Compatible with Hibernate 4.x, 5.x. (5.3.0, 5.3.1 and 5.3.2 versions aren't supported)
Redisson provides various Hibernate Cache factories including those with features below: Redisson provides various Hibernate Cache factories including those with features below:
**local cache** - so called `near cache`, which is useful for use cases when Hibernate Cache used mostly for read operations and/or network roundtrips are undesirable. It caches Map entries on Redisson side and executes read operations up to **5x faster** in comparison with common implementation. All local caches with the same name connected to the same pub/sub channel which is used for messaging between them. In particular to send entity update or entity invalidate event. **local cache** - so called `near cache`, which is useful for use cases when Hibernate Cache used mostly for read operations and/or network roundtrips are undesirable. It caches Map entries on Redisson side and executes read operations up to **5x faster** in comparison with common implementation. All local caches with the same name connected to the same pub/sub channel which is used for messaging between them. In particular to send entity update or entity invalidate event.
**data partitioning** - data partitioning in cluster mode. It allows to scale available memory, read/write operations and entry eviction process for individual Hibernate Cache instance in Redis cluster. **data partitioning** - data partitioning in cluster mode. It allows to scale available memory, read/write operations and entry eviction process for individual Hibernate Cache instance in Redis cluster.
Below is the list of all available factories with local cache and/or data partitioning support: Below is the list of all available factories with local cache and/or data partitioning support:
|Class name | Local cache <br/> support<br/>(up to 5x faster) | Data partitioning <br/> support | |Class name | Local cache <br/> support<br/>(up to 5x faster) | Data partitioning <br/> support |
| ------------- | ------------- | ------------| | ------------- | ------------- | ------------|
@ -22,12 +21,12 @@ Below is the list of all available factories with local cache and/or data partit
|RedissonClusteredRegionFactory<br/><sub><i>available only in [Redisson PRO](http://redisson.pro) edition</i></sub> | No | **Yes** | |RedissonClusteredRegionFactory<br/><sub><i>available only in [Redisson PRO](http://redisson.pro) edition</i></sub> | No | **Yes** |
|RedissonClusteredLocalCachedRegionFactory<br/><sub><i>available only in [Redisson PRO](http://redisson.pro) edition</i></sub> | **Yes** | **Yes** | |RedissonClusteredLocalCachedRegionFactory<br/><sub><i>available only in [Redisson PRO](http://redisson.pro) edition</i></sub> | **Yes** | **Yes** |
Hibernate Cache Usage ## Hibernate Cache Usage
===
### 1. Add `redisson-hibernate` dependency into your project: ### 1. Add `redisson-hibernate` dependency into your project:
Maven Maven
```xml ```xml
<dependency> <dependency>
<groupId>org.redisson</groupId> <groupId>org.redisson</groupId>
@ -45,7 +44,7 @@ Maven
Gradle Gradle
```java ```groovy
// for Hibernate v4.x // for Hibernate v4.x
compile 'org.redisson:redisson-hibernate-4:3.10.6' compile 'org.redisson:redisson-hibernate-4:3.10.6'
// for Hibernate v5.0.x - v5.1.x // for Hibernate v5.0.x - v5.1.x
@ -54,8 +53,7 @@ Gradle
compile 'org.redisson:redisson-hibernate-52:3.10.6' compile 'org.redisson:redisson-hibernate-52:3.10.6'
// for Hibernate v5.3.3+ - v5.4.x // for Hibernate v5.3.3+ - v5.4.x
compile 'org.redisson:redisson-hibernate-53:3.10.6' compile 'org.redisson:redisson-hibernate-53:3.10.6'
``` ```
### 2. Specify hibernate cache settings ### 2. Specify hibernate cache settings
@ -71,7 +69,9 @@ Define Redisson Region Cache Factory:
<!-- or --> <!-- or -->
<property name="hibernate.cache.region.factory_class" value="org.redisson.hibernate.RedissonClusteredLocalCachedRegionFactory" /> <property name="hibernate.cache.region.factory_class" value="org.redisson.hibernate.RedissonClusteredLocalCachedRegionFactory" />
``` ```
By default each Region Factory creates own Redisson instance. For multiple applications, using the same Redis setup and deployed in the same JVM, amount of Redisson instances could be reduced using JNDI registry: By default each Region Factory creates own Redisson instance. For multiple applications, using the same Redis setup and deployed in the same JVM, amount of Redisson instances could be reduced using JNDI registry:
```xml ```xml
<!-- name of Redisson instance registered in JNDI --> <!-- name of Redisson instance registered in JNDI -->
<property name="hibernate.cache.region.jndi_name" value="redisson_instance" /> <property name="hibernate.cache.region.jndi_name" value="redisson_instance" />
@ -96,33 +96,33 @@ By default each Region Factory creates own Redisson instance. For multiple appli
<property name="hibernate.cache.redisson.config" value="/redisson.json" /> <property name="hibernate.cache.redisson.config" value="/redisson.json" />
``` ```
#### Redisson allows to define follow cache settings per entity, collection, naturalid, query and timestamp regions: #### Redisson allows to define follow cache settings per entity, collection, naturalid, query and timestamp regions:
`hibernate.cache.redisson.[REGION_NAME].eviction.max_entries` - max size of cache. Superfluous entries in Redis are evicted using LRU algorithm. `0` value means unbounded cache. Default value: 0 `hibernate.cache.redisson.[REGION_NAME].eviction.max_entries` - max size of cache. Superfluous entries in Redis are evicted using LRU algorithm. `0` value means unbounded cache. Default value: 0
`hibernate.cache.redisson.[REGION_NAME].expiration.time_to_live` - time to live per cache entry in Redis. Defined in milliseconds. `0` value means this setting doesn't affect expiration. Default value: 0 `hibernate.cache.redisson.[REGION_NAME].expiration.time_to_live` - time to live per cache entry in Redis. Defined in milliseconds. `0` value means this setting doesn't affect expiration. Default value: 0
`hibernate.cache.redisson.[REGION_NAME].expiration.max_idle_time` - max idle time per cache entry in Redis. Defined in milliseconds. `0` value means this setting doesn't affect expiration. Default value: 0 `hibernate.cache.redisson.[REGION_NAME].expiration.max_idle_time` - max idle time per cache entry in Redis. Defined in milliseconds. `0` value means this setting doesn't affect expiration. Default value: 0
`hibernate.cache.redisson.[REGION_NAME].localcache.max_idle_time` - max idle time per entry in local cache. Defined in milliseconds. `0` value means this setting doesn't affect expiration. Default value: 0 `hibernate.cache.redisson.[REGION_NAME].localcache.max_idle_time` - max idle time per entry in local cache. Defined in milliseconds. `0` value means this setting doesn't affect expiration. Default value: 0
`hibernate.cache.redisson.[REGION_NAME].localcache.time_to_live` - time to live per entry in local cache. Defined in milliseconds. `0` value means this setting doesn't affect expiration. Default value: 0 `hibernate.cache.redisson.[REGION_NAME].localcache.time_to_live` - time to live per entry in local cache. Defined in milliseconds. `0` value means this setting doesn't affect expiration. Default value: 0
`hibernate.cache.redisson.[REGION_NAME].localcache.eviction_policy` - eviction policy applied to local cache entries when cache size limit reached. LFU, LRU, SOFT, WEAK and NONE policies are available. Default value: NONE `hibernate.cache.redisson.[REGION_NAME].localcache.eviction_policy` - eviction policy applied to local cache entries when cache size limit reached. LFU, LRU, SOFT, WEAK and NONE policies are available. Default value: NONE
`hibernate.cache.redisson.[REGION_NAME].localcache.sync_strategy` - sync strategy used to synchronize local cache changes across all instances. Follow sync strategies are available: `hibernate.cache.redisson.[REGION_NAME].localcache.sync_strategy` - sync strategy used to synchronize local cache changes across all instances. Follow sync strategies are available:
INVALIDATE - Default. Invalidate cache entry across all LocalCachedMap instances on map entry change INVALIDATE - Default. Invalidate cache entry across all LocalCachedMap instances on map entry change
UPDATE - Update cache entry across all LocalCachedMap instances on map entry change UPDATE - Update cache entry across all LocalCachedMap instances on map entry change
NONE - No synchronizations on map changes NONE - No synchronizations on map changes
Default value: INVALIDATE Default value: INVALIDATE
`hibernate.cache.redisson.[REGION_NAME].localcache.reconnection_strategy` - reconnection strategy used to load missed updates through Hibernate during any connection failures to Redis. Since, local cache updates can't be get in absence of connection to Redis. Follow reconnection strategies are available: `hibernate.cache.redisson.[REGION_NAME].localcache.reconnection_strategy` - reconnection strategy used to load missed updates through Hibernate during any connection failures to Redis. Since, local cache updates can't be get in absence of connection to Redis. Follow reconnection strategies are available:
CLEAR - Clear local cache if map instance has been disconnected for a while. CLEAR - Clear local cache if map instance has been disconnected for a while.
LOAD - Store invalidated entry hash in invalidation log for 10 minutes. Cache keys for stored invalidated entry hashes will be removed if LocalCachedMap instance has been disconnected less than 10 minutes or whole cache will be cleaned otherwise. LOAD - Store invalidated entry hash in invalidation log for 10 minutes. Cache keys for stored invalidated entry hashes will be removed if LocalCachedMap instance has been disconnected less than 10 minutes or whole cache will be cleaned otherwise.
NONE - Default. No reconnection handling NONE - Default. No reconnection handling
Default value: NONE Default value: NONE
`hibernate.cache.redisson.[REGION_NAME].localcache.size` - max size of local cache. Superfluous entries in Redis are evicted using defined eviction policy. `0` value means unbounded cache. Default value: 0 `hibernate.cache.redisson.[REGION_NAME].localcache.size` - max size of local cache. Superfluous entries in Redis are evicted using defined eviction policy. `0` value means unbounded cache. Default value: 0

@ -1,5 +1,4 @@
Spring Boot Starter # Spring Boot Starter
===
Integrates Redisson with Spring Boot library. Depends on [Spring Data Redis](https://github.com/redisson/redisson/tree/master/redisson-spring-data#spring-data-redis-integration) module. Integrates Redisson with Spring Boot library. Depends on [Spring Data Redis](https://github.com/redisson/redisson/tree/master/redisson-spring-data#spring-data-redis-integration) module.
@ -7,10 +6,9 @@ Supports Spring Boot 1.3.x, 1.4.x, 1.5.x, 2.0.x, 2.1.x
<sub>Consider __[Redisson PRO](https://redisson.pro)__ version for advanced features and support by SLA.</sub> <sub>Consider __[Redisson PRO](https://redisson.pro)__ version for advanced features and support by SLA.</sub>
Usage ## Usage
===
### 1. Add `redisson-spring-boot-starter` dependency into your project: ### 1. Add `redisson-spring-boot-starter` dependency into your project:
Maven Maven
@ -23,9 +21,10 @@ Maven
``` ```
Gradle Gradle
```java
```groovy
compile 'org.redisson:redisson-spring-boot-starter:3.10.6' compile 'org.redisson:redisson-spring-boot-starter:3.10.6'
``` ```
### 2. Add settings into `application.settings` file ### 2. Add settings into `application.settings` file

@ -1,5 +1,4 @@
Spring Data Redis integration # Spring Data Redis integration
===
Integrates Redisson with Spring Data Redis library. Implements Spring Data's `RedisConnectionFactory` and `ReactiveRedisConnectionFactory` interfaces and allows to interact with Redis through `RedisTemplate` or `ReactiveRedisTemplate` object. Integrates Redisson with Spring Data Redis library. Implements Spring Data's `RedisConnectionFactory` and `ReactiveRedisConnectionFactory` interfaces and allows to interact with Redis through `RedisTemplate` or `ReactiveRedisTemplate` object.
@ -7,10 +6,9 @@ Supports Spring Data Redis 1.6.x, 1.7.x, 1.8.x, 2.0.x, 2.1.x
<sub>Consider __[Redisson PRO](https://redisson.pro)__ version for advanced features and support by SLA.</sub> <sub>Consider __[Redisson PRO](https://redisson.pro)__ version for advanced features and support by SLA.</sub>
Usage ## Usage
===
### 1. Add `redisson-spring-data` dependency into your project: ### 1. Add `redisson-spring-data` dependency into your project:
Maven Maven
@ -33,7 +31,7 @@ Maven
Gradle Gradle
```java ```groovy
// for Spring Data Redis v.1.6.x // for Spring Data Redis v.1.6.x
compile 'org.redisson:redisson-spring-data-16:3.10.6' compile 'org.redisson:redisson-spring-data-16:3.10.6'
// for Spring Data Redis v.1.7.x // for Spring Data Redis v.1.7.x
@ -44,24 +42,24 @@ Gradle
compile 'org.redisson:redisson-spring-data-20:3.10.6' compile 'org.redisson:redisson-spring-data-20:3.10.6'
// for Spring Data Redis v.2.1.x // for Spring Data Redis v.2.1.x
compile 'org.redisson:redisson-spring-data-21:3.10.6' compile 'org.redisson:redisson-spring-data-21:3.10.6'
``` ```
### 2. Register `RedissonConnectionFactory` in Spring context ### 2. Register `RedissonConnectionFactory` in Spring context
```java ```java
@Configuration @Configuration
public class RedissonSpringDataConfig { public class RedissonSpringDataConfig {
@Bean @Bean
public RedissonConnectionFactory redissonConnectionFactory(RedissonClient redisson) { public RedissonConnectionFactory redissonConnectionFactory(RedissonClient redisson) {
return new RedissonConnectionFactory(redisson); return new RedissonConnectionFactory(redisson);
} }
@Bean(destroyMethod = "shutdown") @Bean(destroyMethod = "shutdown")
public RedissonClient redisson(@Value("classpath:/redisson.yaml") Resource configFile) throws IOException { public RedissonClient redisson(@Value("classpath:/redisson.yaml") Resource configFile) throws IOException {
Config config = Config.fromYAML(configFile.getInputStream()); Config config = Config.fromYAML(configFile.getInputStream());
return Redisson.create(config); return Redisson.create(config);
} }
} }
``` ```

@ -1,24 +1,21 @@
Redis based Tomcat Session Manager # Redis based Tomcat Session Manager
===
Stores session of [Apache Tomcat](http://tomcat.apache.org) in Redis and allows to distribute requests across a cluster of Tomcat servers. Implements non-sticky session management backed by Redis. Stores session of [Apache Tomcat](http://tomcat.apache.org) in Redis and allows to distribute requests across a cluster of Tomcat servers. Implements non-sticky session management backed by Redis.
Supports Apache Tomcat 6.x, 7.x, 8.x, 9.x Supports Apache Tomcat 6.x, 7.x, 8.x, 9.x
<sub>Consider __[Redisson PRO](https://redisson.pro)__ version for advanced features and support by SLA.</sub> <sub>Consider __[Redisson PRO](https://redisson.pro)__ version for advanced features and support by SLA.</sub>
Advantages ## Advantages
===
Current implementation differs from any other Redis based Tomcat Session Manager in terms of efficient storage and optimized writes. Each session attribute is written into Redis during each `HttpSession.setAttribute` invocation. While other solutions serialize whole session each time. Current implementation differs from any other Redis based Tomcat Session Manager in terms of efficient storage and optimized writes. Each session attribute is written into Redis during each `HttpSession.setAttribute` invocation. While other solutions serialize whole session each time.
Usage ## Usage
===
### 1. Add `RedissonSessionManager` ### 1. Add `RedissonSessionManager`
Add `RedissonSessionManager` into `tomcat/conf/context.xml` Add `RedissonSessionManager` into `tomcat/conf/context.xml`
```xml ```xml
<Manager className="org.redisson.tomcat.RedissonSessionManager" <Manager className="org.redisson.tomcat.RedissonSessionManager"
configPath="${catalina.base}/redisson.conf" configPath="${catalina.base}/redisson.conf"
@ -28,9 +25,9 @@ Add `RedissonSessionManager` into `tomcat/conf/context.xml`
* `MEMORY` - stores attributes into local Tomcat Session and Redis. Further Session updates propagated to local Tomcat Session using Redis-based events. * `MEMORY` - stores attributes into local Tomcat Session and Redis. Further Session updates propagated to local Tomcat Session using Redis-based events.
* `REDIS` - stores attributes into Redis only. Default mode. * `REDIS` - stores attributes into Redis only. Default mode.
<br/> <br/>
`broadcastSessionEvents` - if `true` then `sessionCreated` and `sessionDestroyed` events broadcasted across all Tomcat instances and trigger all registered HttpSessionListeners. Default is `false`. `broadcastSessionEvents` - if `true` then `sessionCreated` and `sessionDestroyed` events broadcasted across all Tomcat instances and trigger all registered HttpSessionListeners. Default is `false`.
`updateMode` - Session attributes update mode. Two modes are available: `updateMode` - Session attributes update mode. Two modes are available:
* `DEFAULT` - session attributes are stored into Redis only through setAttribute method. Default mode. * `DEFAULT` - session attributes are stored into Redis only through setAttribute method. Default mode.
* `AFTER_REQUEST` - all session attributes are stored into Redis after each request. * `AFTER_REQUEST` - all session attributes are stored into Redis after each request.
@ -46,7 +43,7 @@ Add `RedissonSessionManager` into `tomcat/conf/context.xml`
```xml ```xml
<GlobalNamingResources> <GlobalNamingResources>
<Resource name="bean/redisson" <Resource name="bean/redisson"
auth="Container" auth="Container"
factory="org.redisson.JndiRedissonFactory" factory="org.redisson.JndiRedissonFactory"
configPath="${catalina.base}/conf/redisson.yaml" configPath="${catalina.base}/conf/redisson.yaml"
@ -67,6 +64,7 @@ Add `RedissonSessionManager` into `tomcat/conf/context.xml`
``` ```
### 2. Copy two jars into `TOMCAT_BASE/lib` directory: ### 2. Copy two jars into `TOMCAT_BASE/lib` directory:
[redisson-all-3.10.7.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-all&v=3.10.7&e=jar) [redisson-all-3.10.7.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-all&v=3.10.7&e=jar)
@ -78,4 +76,4 @@ for Tomcat 8.x
[redisson-tomcat-8-3.10.7.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-8&v=3.10.7&e=jar) [redisson-tomcat-8-3.10.7.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-8&v=3.10.7&e=jar)
for Tomcat 9.x for Tomcat 9.x
[redisson-tomcat-9-3.10.7.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-9&v=3.10.7&e=jar) [redisson-tomcat-9-3.10.7.jar](https://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=org.redisson&a=redisson-tomcat-9&v=3.10.7&e=jar)

Loading…
Cancel
Save