Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nouiWithSpringMVC
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gechengyang
nouiWithSpringMVC
Commits
75494fa3
Commit
75494fa3
authored
Jan 20, 2021
by
WeiCong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加缓存支持模式
parent
3ce9653a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
25 deletions
+40
-25
AbstractCache.java
...n/java/org/sss/presentation/noui/cache/AbstractCache.java
+40
-25
eibs-container-3.5.0.jar
src/main/webapp/WEB-INF/lib/eibs-container-3.5.0.jar
+0
-0
eibs-hibernatesupport-2.0.0.jar
src/main/webapp/WEB-INF/lib/eibs-hibernatesupport-2.0.0.jar
+0
-0
eibs-mybatissupport-1.0.0.jar
src/main/webapp/WEB-INF/lib/eibs-mybatissupport-1.0.0.jar
+0
-0
eibs-pojosupport-2.0.0.jar
src/main/webapp/WEB-INF/lib/eibs-pojosupport-2.0.0.jar
+0
-0
No files found.
src/main/java/org/sss/presentation/noui/cache/AbstractCache.java
View file @
75494fa3
...
...
@@ -5,15 +5,19 @@ import org.hibernate.Query;
import
org.hibernate.internal.QueryImpl
;
import
org.sss.common.model.CacheController
;
import
org.sss.common.model.IModuleList
;
import
org.sss.module.pojo.EibsResultSet
;
import
org.sss.presentation.noui.api.exception.NoUiException
;
import
org.sss.presentation.noui.common.Constants
;
import
java.sql.SQLException
;
import
java.util.List
;
import
java.util.Map
;
public
abstract
class
AbstractCache
implements
CacheController
{
public
static
final
ThreadLocal
paginationMap
=
new
ThreadLocal
();
protected
final
String
cacheName
;
final
String
SPLIT
=
"__"
;
public
static
final
ThreadLocal
paginationMap
=
new
ThreadLocal
()
;
final
String
NULL
=
"NULL"
;
public
AbstractCache
(
String
redis_cache
)
{
this
.
cacheName
=
redis_cache
;
...
...
@@ -43,6 +47,19 @@ public abstract class AbstractCache implements CacheController {
query
.
setFirstResult
(
offset
);
}
lst
=
query
.
list
();
}
else
if
(
o
instanceof
EibsResultSet
)
{
EibsResultSet
eibsResultSet
=
(
EibsResultSet
)
o
;
if
(
maxSize
>
0
)
{
eibsResultSet
.
setMaxResults
(
maxSize
);
}
if
(
offset
>
0
)
{
eibsResultSet
.
setFirstResult
(
offset
);
}
try
{
lst
=
eibsResultSet
.
list
();
}
catch
(
SQLException
e
)
{
throw
new
NoUiException
(
"["
+
this
.
cacheName
+
"]执行sql出现异常"
,
e
);
}
}
doCacheWrite
(
key
,
lst
,
keepAlive
);
}
...
...
@@ -52,7 +69,23 @@ public abstract class AbstractCache implements CacheController {
private
String
generateKey
(
Object
o
,
int
maxSize
,
int
offset
)
{
StringBuffer
sb
=
new
StringBuffer
(
cacheName
);
sb
.
append
(
SPLIT
.
intern
());
sb
.
append
(
o
.
toString
());
if
(
o
instanceof
EibsResultSet
)
{
sb
.
append
(((
EibsResultSet
)
o
).
getSql
());
}
else
{
sb
.
append
(
o
.
toString
());
}
if
(
o
instanceof
EibsResultSet
||
o
instanceof
QueryImpl
)
{
Object
[]
values
=
o
instanceof
EibsResultSet
?
((
EibsResultSet
)
o
).
getArgs
()
:
((
QueryImpl
)
o
).
valueArray
();
if
(
values
!=
null
)
{
for
(
Object
val
:
values
)
{
sb
.
append
(
SPLIT
.
intern
());
if
(
val
==
null
)
{
sb
.
append
(
NULL
.
intern
());
}
else
sb
.
append
(
val
.
toString
());
}
}
}
if
(
maxSize
>
0
)
{
sb
.
append
(
SPLIT
.
intern
());
sb
.
append
(
maxSize
);
...
...
@@ -61,36 +94,18 @@ public abstract class AbstractCache implements CacheController {
sb
.
append
(
SPLIT
.
intern
());
sb
.
append
(
offset
);
}
//添加数据计算key
if
(
o
instanceof
QueryImpl
)
{
Object
[]
values
=
((
QueryImpl
)
o
).
valueArray
();
if
(
values
!=
null
)
{
for
(
Object
val:
values
)
{
if
(
val
==
null
)
{
sb
.
append
(
"null"
);
}
else
sb
.
append
(
val
.
toString
());
sb
.
append
(
','
);
}
}
}
return
sb
.
toString
();
}
@Override
public
void
prepareReadset
(
IModuleList
moduleList
)
{
Map
<
String
,
Map
<
String
,
Integer
>>
paginationCache
=
(
Map
<
String
,
Map
<
String
,
Integer
>>)
paginationMap
.
get
();
if
(
paginationCache
==
null
)
Map
<
String
,
Map
<
String
,
Integer
>>
paginationCache
=
(
Map
<
String
,
Map
<
String
,
Integer
>>)
paginationMap
.
get
();
if
(
paginationCache
==
null
)
return
;
Map
<
String
,
Integer
>
paginationItem
=
paginationCache
.
remove
(
moduleList
.
getUrl
());
if
(
paginationCache
.
size
()
==
0
)
Map
<
String
,
Integer
>
paginationItem
=
paginationCache
.
remove
(
moduleList
.
getUrl
());
if
(
paginationCache
.
size
()
==
0
)
paginationMap
.
remove
();
if
(
paginationItem
==
null
)
if
(
paginationItem
==
null
)
return
;
moduleList
.
setPageSize
(
paginationItem
.
get
(
Constants
.
PAGINATION_PAGESIZE
));
moduleList
.
setPage
(
paginationItem
.
get
(
Constants
.
PAGINATION_INDEX
));
...
...
src/main/webapp/WEB-INF/lib/eibs-container-3.5.0.jar
View file @
75494fa3
No preview for this file type
src/main/webapp/WEB-INF/lib/eibs-hibernatesupport-2.0.0.jar
View file @
75494fa3
No preview for this file type
src/main/webapp/WEB-INF/lib/eibs-mybatissupport-1.0.0.jar
View file @
75494fa3
No preview for this file type
src/main/webapp/WEB-INF/lib/eibs-pojosupport-2.0.0.jar
View file @
75494fa3
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment