Application
-
Declaration
Swift
fileprivate static var ucs: UserCacheStorage?
-
Declaration
Swift
private static var ucsLock: NIOLock
-
This is where UserCache stores its in-memory cache.
Declaration
Swift
static var userCacheStorage: UserCacheStorage { get set }
-
This is the datatype that gets stored in UserCacheStorage. Vapor’s Services API uses this.
See moreDeclaration
Swift
struct UserCacheStorage
-
Storage key used by Vapor’s Services API. Used by UserCache to access its cache data.
See moreDeclaration
Swift
struct UserCacheStorageKey : StorageKey
-
A simple mutex lock provided by Vapor’s Services API.. All code blocks that are protected with this lock’s
withLock()
method are serialized against each other.Declaration
Swift
struct UserCacheLockKey : LockKey
-
initializeUserCache(_:
Asynchronous) After boot but before handling requests, this code runs to fill the cache with data on all known
User
s. LifecycleHandler is another part of Vapor’s Services API. Load all users into cache at startup.Declaration
Swift
func initializeUserCache(_ app: Application) async throws
-
Declaration
Swift
func getUserHeader(_ username: String) -> UserHeader?
-
This is where we store active WebSockets.
Declaration
Swift
var websocketStorage: WebSocketStorage { get set }
-
This is the datatype that gets stored in UserCacheStorage. Vapor’s Services API uses this. Making this a class instead of a struct. This prevents internal modifications (e.g. adding/removing a value from the dicts) from causing the entire app.storage getting copied, in the case where app.storage is a value type composed of other value types. The custom setter for app.storage is not thread-safe. So, this is a workaround for app.storage having a non-thread-safe setter.
See moreDeclaration
Swift
class WebSocketStorage
-
Storage key used by Vapor’s Services API. Used by UserCache to access its cache data.
See moreDeclaration
Swift
struct WebSocketStorageKey : StorageKey
-
A simple mutex lock provided by Vapor’s Services API.. All code blocks that are protected with this lock’s
withLock()
method are serialized against each other.Declaration
Swift
struct WebSocketStorageLockKey : LockKey