Skip to content

Commit 4f5f8b7

Browse files
committed
Release 3.1.0
1 parent 16ac6b9 commit 4f5f8b7

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

README.md

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ You can choose these 2 ways to include shiro-redis into your project
1616
<dependency>
1717
<groupId>org.crazycake</groupId>
1818
<artifactId>shiro-redis</artifactId>
19-
<version>3.0.0</version>
19+
<version>3.1.0</version>
2020
</dependency>
2121
```
2222

2323
> **Note:**\
24-
> Do not use version < 3.0.0\
24+
> Do not use version < 3.1.0\
2525
> **注意**\
26-
> 请不要使用3.0.0以下版本
26+
> 请不要使用3.1.0以下版本
2727
2828
# Before use
29-
Here is the first thing you need to know. Shiro-redis needs an id field to identify your authorization object in Redis. So please make sure your principal class has a field which you can get unique id of this object. Please setting this id field name by `cacheManager.principalId = id`
29+
Here is the first thing you need to know. Shiro-redis needs an id field to identify your authorization object in Redis. So please make sure your principal class has a field which you can get unique id of this object. Please setting this id field name by `cacheManager.principalIdFieldName = <your id field name of principal object>`
3030

3131
For example:
3232

@@ -41,16 +41,14 @@ protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token)
4141
}
4242
```
4343

44-
You need to make sure `UserInfo` has an unique field to identify it in Redis. Take userId as an example:
44+
Then the userInfo object is your principal object. You need to make sure `UserInfo` has an unique field to identify it in Redis. Take userId as an example:
4545
```java
4646
public class UserInfo implements Serializable{
4747

4848
private Integer userId
4949

5050
private String username;
5151

52-
private Integer age;
53-
5452
public String getUsername() {
5553
return username;
5654
}
@@ -59,25 +57,24 @@ public class UserInfo implements Serializable{
5957
this.username = username;
6058
}
6159

62-
public Integer getAge() {
63-
return age;
64-
}
65-
66-
public void setAge(Integer age) {
67-
this.age = age;
68-
}
69-
7060
public Integer getUserId() {
7161
return this.userId;
7262
}
7363
}
7464
```
7565

76-
And put userId as `cacheManager.principalId`, like this:
66+
Put userId as the value of `cacheManager.principalIdFieldName`, like this:
7767
```properties
78-
cacheManager.principalId = userId
68+
cacheManager.principalIdFieldName = userId
7969
```
8070

71+
If you're using Spring, the configuration should be
72+
```xml
73+
<property name="principalIdFieldName" value="userId" />
74+
```
75+
76+
Then shiro-redis will call `userInfo.getUserId()` to get the id for storing Redis object.
77+
8178
# How to configure ?
8279

8380
You can configure shiro-redis either in `shiro.ini` or in `spring-*.xml`

0 commit comments

Comments
 (0)