Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
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
YZG
yzg-util
Commits
5bd236fc
Commit
5bd236fc
authored
Nov 12, 2021
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改实例化关系
parent
1fddc0e2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
3 deletions
+30
-3
MediaCacheLocal.java
.../src/main/java/com/yanzuoguang/media/MediaCacheLocal.java
+30
-3
No files found.
yzg-util-image/src/main/java/com/yanzuoguang/media/MediaCacheLocal.java
View file @
5bd236fc
package
com
.
yanzuoguang
.
media
;
package
com
.
yanzuoguang
.
media
;
import
com.yanzuoguang.util.helper.JsonHelper
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -21,7 +23,22 @@ public class MediaCacheLocal implements MediaCacheBase {
...
@@ -21,7 +23,22 @@ public class MediaCacheLocal implements MediaCacheBase {
*/
*/
@Override
@Override
public
MediaResVo
start
(
MediaReqVo
req
,
Runnable
runnable
)
{
public
MediaResVo
start
(
MediaReqVo
req
,
Runnable
runnable
)
{
return
null
;
// 获取锁
MapLock
mapLock
=
getMapLock
(
req
);
// 锁定缓存对象,防止多人执行
synchronized
(
mapLock
)
{
// 读取历史缓存
MediaResVo
tempRes
=
mapLock
.
res
;
// 写入结果到缓存
mapLock
.
res
=
JsonHelper
.
to
(
req
,
MediaResVo
.
class
);
// 判断历史缓存的次数,确定是否执行
if
(
tempRes
==
null
||
tempRes
.
getCount
()
<
1
)
{
// 执行时,会开启线程下载视频,并转换为截图文件
runnable
.
run
();
}
// 返回缓存中的结果
return
mapLock
.
res
;
}
}
}
/**
/**
...
@@ -32,7 +49,12 @@ public class MediaCacheLocal implements MediaCacheBase {
...
@@ -32,7 +49,12 @@ public class MediaCacheLocal implements MediaCacheBase {
*/
*/
@Override
@Override
public
MediaResVo
get
(
MediaReqVo
req
)
{
public
MediaResVo
get
(
MediaReqVo
req
)
{
return
null
;
// 获取锁
MapLock
mapLock
=
getMapLock
(
req
);
// 锁定缓存对象,防止多人执行
synchronized
(
mapLock
)
{
return
mapLock
.
res
;
}
}
}
/**
/**
...
@@ -42,7 +64,12 @@ public class MediaCacheLocal implements MediaCacheBase {
...
@@ -42,7 +64,12 @@ public class MediaCacheLocal implements MediaCacheBase {
*/
*/
@Override
@Override
public
void
sub
(
MediaResVo
res
)
{
public
void
sub
(
MediaResVo
res
)
{
// 获取锁
MapLock
mapLock
=
getMapLock
(
res
);
// 锁定缓存对象,防止多人执行
synchronized
(
mapLock
)
{
mapLock
.
res
.
subCount
();
}
}
}
/**
/**
...
...
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