-
Notifications
You must be signed in to change notification settings - Fork 198
/
Copy pathcaching.urm.puml
110 lines (110 loc) · 3.47 KB
/
caching.urm.puml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
@startuml
package com.iluwatar.caching {
class App {
- LOGGER : Logger {static}
+ App()
+ main(args : String[]) {static}
+ useCacheAsideStategy()
+ useReadAndWriteThroughStrategy()
+ useReadThroughAndWriteAroundStrategy()
+ useReadThroughAndWriteBehindStrategy()
}
class AppManager {
- cachingPolicy : CachingPolicy {static}
- AppManager()
+ find(userId : String) : UserAccount {static}
- findAside(userId : String) : UserAccount {static}
+ initCacheCapacity(capacity : int) {static}
+ initCachingPolicy(policy : CachingPolicy) {static}
+ initDb(useMongoDb : boolean) {static}
+ printCacheContent() : String {static}
+ save(userAccount : UserAccount) {static}
- saveAside(userAccount : UserAccount) {static}
}
class CacheStore {
- LOGGER : Logger {static}
~ cache : LruCache {static}
- CacheStore()
+ clearCache() {static}
+ flushCache() {static}
+ get(userId : String) : UserAccount {static}
+ initCapacity(capacity : int) {static}
+ invalidate(userId : String) {static}
+ print() : String {static}
+ readThrough(userId : String) : UserAccount {static}
+ readThroughWithWriteBackPolicy(userId : String) : UserAccount {static}
+ set(userId : String, userAccount : UserAccount) {static}
+ writeAround(userAccount : UserAccount) {static}
+ writeBehind(userAccount : UserAccount) {static}
+ writeThrough(userAccount : UserAccount) {static}
}
enum CachingPolicy {
+ AROUND {static}
+ ASIDE {static}
+ BEHIND {static}
+ THROUGH {static}
- policy : String
+ getPolicy() : String
+ valueOf(name : String) : CachingPolicy {static}
+ values() : CachingPolicy[] {static}
}
class DbManager {
- db : MongoDatabase {static}
- mongoClient : MongoClient {static}
- useMongoDB : boolean {static}
- virtualDB : Map<String, UserAccount> {static}
- DbManager()
+ connect() {static}
+ createVirtualDb() {static}
+ readFromDb(userId : String) : UserAccount {static}
+ updateDb(userAccount : UserAccount) {static}
+ upsertDb(userAccount : UserAccount) {static}
+ writeToDb(userAccount : UserAccount) {static}
}
class LruCache {
- LOGGER : Logger {static}
~ cache : Map<String, Node>
~ capacity : int
~ end : Node
~ head : Node
+ LruCache(capacity : int)
+ clear()
+ contains(userId : String) : boolean
+ get(userId : String) : UserAccount
+ getCacheDataInListForm() : List<UserAccount>
+ getLruData() : UserAccount
+ invalidate(userId : String)
+ isFull() : boolean
+ remove(node : Node)
+ set(userId : String, userAccount : UserAccount)
+ setCapacity(newCapacity : int)
+ setHead(node : Node)
}
~class Node {
~ next : Node
~ previous : Node
~ userAccount : UserAccount
~ userId : String
+ Node(this$0 : String, userId : UserAccount)
}
class UserAccount {
- additionalInfo : String
- userId : String
- userName : String
+ UserAccount(userId : String, userName : String, additionalInfo : String)
+ getAdditionalInfo() : String
+ getUserId() : String
+ getUserName() : String
+ setAdditionalInfo(additionalInfo : String)
+ setUserId(userId : String)
+ setUserName(userName : String)
+ toString() : String
}
}
LruCache --> "-head" Node
Node --+ LruCache
Node --> "-previous" Node
AppManager --> "-cachingPolicy" CachingPolicy
Node --> "-userAccount" UserAccount
CacheStore --> "-cache" LruCache
@enduml