package/@git/url_0eb7c89453c87681ed15@0.0.0-git.a39fc582565d4fca40be4f75fa304d71adc69301/store.aug diagrams
OpenID Connect login application
Project overview · Compiled explanation
Class interactions
Mermaid source
flowchart TD
n0["ExpiringStore"]
n1["MemoryStore"]
n1 -->|"implements"| n0
Sequences
Call arrows identify checked targets; loop and branch frames determine when they run. Open that target’s module to follow its implementation. Branches describe alternatives; loops describe repeated work. Native calls and interface dispatch stop at their declared contracts. Exit notes end that path; enclosing recovery and cleanup remain visible.
StoreFull constructor
The bounded store could not accept another live entry. It implements Error.
_Entry constructor
It is private to this file. The type parameters are T which must satisfy Data.
It takes value as T, kept read-only and expires as an integer, kept read-only.
Receive fields: value, expires. Explanation.
ExpiringStore.put
Remove expired entries, then store at most 512 live entries. Time is supplied by the caller.
It takes key as a string, value as T, and expires and now as integers.
It can call ExpiringStore.put. Failures can raise StoreFull.
May leave with checked errors: StoreFull. Interface contract; implementation selected at runtime. Explanation.
ExpiringStore.take
Atomically remove a value. Expired or absent entries return null.
It takes key as a string and now as an integer.
It returns optional T. It can call ExpiringStore.take.
Interface contract; implementation selected at runtime. Explanation.
ExpiringStore.get
Read a live value without consuming it.
It takes key as a string and now as an integer.
It returns optional T. It can call ExpiringStore.get.
Interface contract; implementation selected at runtime. Explanation.
MemoryStore constructor
A synchronized table with short critical sections and no I/O while locked. It implements ExpiringStore<T>. The type parameters are T which must satisfy Data.
The read-only, private field _entries has type Shared<Map<string,_Entry<T>>> and starts as a Shared with value from an empty map from string to _Entry<T>.
Mermaid source
sequenceDiagram
participant p0 as MemoryStore constructor
participant p1 as Shared
p0->>p0: Map‹string, _Entry‹T››()
p0-->>p0: Map result: Map‹string, _Entry‹T››
p0->>p1: Shared(value=Map result)
p1-->>p0: _entries: Shared‹Map‹string, _Entry‹T›››
MemoryStore.put
Remove expired entries, then store at most 512 live entries. Time is supplied by the caller.
It takes key as a string, value as T, and expires and now as integers.
It can call ExpiringStore<T>.put. Failures can raise StoreFull.
Mermaid source
sequenceDiagram
participant p0 as MemoryStore.put
p0->>p0: _Entry‹T›(value=value, expires=expires) · construct<br/>value
p0-->>p0: entry: _Entry‹T›
rect rgb(245, 240, 241)
Note over p0: Enter lock scope
loop For each item in entries
alt saved.expires is at most now
p0->>p0: entries.take(key=name)
p0-->>p0: take result: optional _Entry‹T›
end
end
p0->>p0: entries.length()
p0-->>p0: length result: int
opt (length result ›= 512) is true
p0->>p0: entries.contains(key=key)
p0-->>p0: contains result: bool
end
alt the number of elements in entries is at least 512 and<br/>whether entries contains the key key returns false
p0->>p0: StoreFull() · construct value
p0-->>p0: StoreFull result: StoreFull
Note over p0: Raise checked failure StoreFull(); required cleanup runs<br/>before exit
end
p0->>p0: entries.set(key=key, value=entry)
Note over p0: Leave lock scope
end
Note over p0: May leave with checked errors: StoreFull
MemoryStore.take
Atomically remove a value. Expired or absent entries return null.
It takes key as a string and now as an integer.
It can call ExpiringStore<T>.take.
Mermaid source
sequenceDiagram
participant p0 as MemoryStore.take
rect rgb(245, 240, 241)
Note over p0: Enter lock scope
p0->>p0: entries.take(key=key)
p0-->>p0: take result: optional _Entry‹T›
alt Match when null:
Note over p0: Return null; required cleanup runs before exit
else Match when some saved:
alt saved.expires is at most now
Note over p0: Return null; required cleanup runs before exit
end
Note over p0: Return saved.value; required cleanup runs before exit
end
Note over p0: Leave lock scope
end
MemoryStore.get
Read a live value without consuming it.
It takes key as a string and now as an integer.
It can call ExpiringStore<T>.get.
Mermaid source
sequenceDiagram
participant p0 as MemoryStore.get
rect rgb(245, 240, 241)
Note over p0: Enter lock scope
p0->>p0: entries.get(key=key)
p0-->>p0: get result: optional _Entry‹T›
alt Match when null:
Note over p0: Return null; required cleanup runs before exit
else Match when some saved:
alt saved.expires is at most now
Note over p0: Return null; required cleanup runs before exit
end
Note over p0: Return saved.value; required cleanup runs before exit
end
Note over p0: Leave lock scope
end
Called contracts
- ExpiringStore — package/@git/url_0eb7c89453c87681ed15@0.0.0-git.a39fc582565d4fca40be4f75fa304d71adc69301/store.aug
- StoreFull — package/@git/url_0eb7c89453c87681ed15@0.0.0-git.a39fc582565d4fca40be4f75fa304d71adc69301/store.aug
- _Entry — package/@git/url_0eb7c89453c87681ed15@0.0.0-git.a39fc582565d4fca40be4f75fa304d71adc69301/store.aug