You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14-17Lines changed: 14 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,17 +16,17 @@ You can choose these 2 ways to include shiro-redis into your project
16
16
<dependency>
17
17
<groupId>org.crazycake</groupId>
18
18
<artifactId>shiro-redis</artifactId>
19
-
<version>3.0.0</version>
19
+
<version>3.1.0</version>
20
20
</dependency>
21
21
```
22
22
23
23
> **Note:**\
24
-
> Do not use version < 3.0.0\
24
+
> Do not use version < 3.1.0\
25
25
> **注意**:\
26
-
> 请不要使用3.0.0以下版本
26
+
> 请不要使用3.1.0以下版本
27
27
28
28
# 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>`
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:
45
45
```java
46
46
publicclassUserInfoimplementsSerializable{
47
47
48
48
privateInteger userId
49
49
50
50
privateString username;
51
51
52
-
privateInteger age;
53
-
54
52
publicStringgetUsername() {
55
53
return username;
56
54
}
@@ -59,25 +57,24 @@ public class UserInfo implements Serializable{
59
57
this.username = username;
60
58
}
61
59
62
-
publicIntegergetAge() {
63
-
return age;
64
-
}
65
-
66
-
publicvoidsetAge(Integerage) {
67
-
this.age = age;
68
-
}
69
-
70
60
publicIntegergetUserId() {
71
61
returnthis.userId;
72
62
}
73
63
}
74
64
```
75
65
76
-
And put userId as `cacheManager.principalId`, like this:
66
+
Put userId as the value of `cacheManager.principalIdFieldName`, like this:
77
67
```properties
78
-
cacheManager.principalId = userId
68
+
cacheManager.principalIdFieldName = userId
79
69
```
80
70
71
+
If you're using Spring, the configuration should be
0 commit comments