Libraryless. Click here for Pure Java version (3159L/21K/68K).
1 | // Logic: Checks every 10 seconds and clears full cache when |
2 | // anything changed in the DB. So it's as good as traffic-free |
3 | // when the DB is not changing. |
4 | |
5 | !752 |
6 | |
7 | m {
|
8 | static int updateInterval = 10000; |
9 | static long lastVersionCount; |
10 | |
11 | static new Map<S, S> md5s; |
12 | |
13 | p {
|
14 | startBot("Version Count Bot", "#1001745");
|
15 | makeBot("Snippet MD5 Bot.");
|
16 | updateLoop(); |
17 | } |
18 | |
19 | static void update() {
|
20 | new Matches m; |
21 | if (match("version count: *", sendToLocalBot_cached("Version Count Bot", "get version count"), m)) {
|
22 | long count = parseLong(m.get(0)); |
23 | if (count != lastVersionCount) {
|
24 | lastVersionCount = count; |
25 | clear(); |
26 | } |
27 | } |
28 | } |
29 | |
30 | static synchronized S answer(S s) {
|
31 | new Matches m; |
32 | if (match3("what is the md5 of snippet *", s, m)) {
|
33 | S snippetID = formatSnippetID(m.unq(0)); |
34 | S md5 = md5s.get(snippetID); |
35 | if (md5 == null) {
|
36 | md5 = getSnippetMD5(snippetID); |
37 | if (md5 == null) ret "null"; |
38 | md5s.put(snippetID, md5); |
39 | } |
40 | ret format("The md5 of snippet * is *.", snippetID, md5);
|
41 | } |
42 | |
43 | if (match3("clear snippet md5 cache", s, m)) {
|
44 | clear(); |
45 | ret "OK."; |
46 | } |
47 | |
48 | if (match3("get snippet md5 cache size", s, m)) {
|
49 | ret "Cache entries: " + md5s.size(); |
50 | } |
51 | |
52 | ret null; |
53 | } |
54 | |
55 | static synchronized void clear() {
|
56 | md5s.clear(); |
57 | } |
58 | } |
Began life as a copy of #1001747
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1002079 |
| Snippet name: | Snippet MD5 Bot (seems to work) |
| Eternal ID of this version: | #1002079/1 |
| Text MD5: | 03c8af50115cf5ffd963ce0f95c1512c |
| Transpilation MD5: | 1ecf716a6e1f2956145d8d859c2b044c |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2016-02-03 18:52:48 |
| Source code size: | 1436 bytes / 58 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 819 / 1602 |
| Referenced in: | [show references] |