Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
63c3a64c
Commit
63c3a64c
authored
Feb 22, 2020
by
ryoii
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http api quote cache
parent
87af0cd0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
+8
-4
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/queue/MessageQueue.kt
...ain/kotlin/net/mamoe/mirai/api/http/queue/MessageQueue.kt
+8
-4
No files found.
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/queue/MessageQueue.kt
View file @
63c3a64c
...
...
@@ -15,16 +15,17 @@ import net.mamoe.mirai.api.http.data.common.toDTO
import
net.mamoe.mirai.event.events.BotEvent
import
net.mamoe.mirai.message.GroupMessage
import
net.mamoe.mirai.message.data.MessageSource
import
java.util.concurrent.ConcurrentHashMap
import
net.mamoe.mirai.utils.firstKey
import
java.util.concurrent.ConcurrentLinkedDeque
class
MessageQueue
:
ConcurrentLinkedDeque
<
BotEvent
>()
{
val
quoteCache
=
ConcurrentHashMap
<
Long
,
GroupMessage
>()
val
quoteCacheSize
=
4096
val
quoteCache
=
LinkedHashMap
<
Long
,
GroupMessage
>()
fun
fetch
(
size
:
Int
):
List
<
EventDTO
>
{
var
count
=
size
quoteCache
.
clear
()
val
ret
=
ArrayList
<
EventDTO
>(
count
)
while
(!
this
.
isEmpty
()
&&
count
>
0
)
{
val
event
=
pop
()
...
...
@@ -44,6 +45,9 @@ class MessageQueue : ConcurrentLinkedDeque<BotEvent>() {
}
private
fun
addCache
(
msg
:
GroupMessage
)
{
quoteCache
[
msg
.
message
[
MessageSource
].
messageUid
.
toLong
()
and
0
xFFffFFff
]
=
msg
quoteCache
[
msg
.
message
[
MessageSource
].
messageUid
.
toLong
()]
=
msg
if
(
quoteCache
.
size
>
quoteCacheSize
)
{
quoteCache
.
remove
(
quoteCache
.
firstKey
())
}
}
}
\ No newline at end of file
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