RedisClient
extension RedisClient
This extends Request.Redis with a bunch of function wrappers that (mostly) make a single Redis call. The function names describe what the functions do in Swiftarr API terms, keeping the Redis keys and specific commands used internal to this file. When looking at the Redis database you can refer to this file to see what various keys are used for, and having all the Redis code here makes it much easier to reason about changes to how we structure data in Redis.
Unlike Postgres with Fluent, Redis doesn’t provide us with a centralized data model for how the db is structured. Having code all over the app call hset directly makes it difficult to answer questions like, “What fields should exist in this hash set?” So, all that is centralized here.
-
addUsersWithStateChange(_:
Asynchronous) Declaration
Swift
func addUsersWithStateChange(_ userIDs: [UUID]) async throws
-
testAndClearStateChange(_:
Asynchronous) Declaration
Swift
func testAndClearStateChange(_ userID: UUID) async throws -> Bool
-
Declaration
Swift
func userHashRedisKey(userID: UUID) -> RedisKey
-
getUserHash(userID:
Asynchronous) Declaration
Swift
func getUserHash(userID: UUID) async throws -> [String : RESPValue]
-
Declaration
Swift
func getIntFromUserHash(_ hash: [String : RESPValue], field: NotificationType, viewed: Bool = false) -> Int
-
Declaration
Swift
func getUUIDFromUserHash(_ hash: [String : RESPValue], field: NotificationType) -> UUID?
-
Declaration
Swift
func getNextEventFromUserHash(_ hash: [String : RESPValue]) -> (Date, UUID)?
-
Declaration
Swift
func getNextLFGFromUserHash(_ hash: [String : RESPValue]) -> (Date, UUID)?
-
markAllViewedInUserHash(field:
AsynchronoususerID: ) Declaration
Swift
func markAllViewedInUserHash(field: NotificationType, userID: UUID) async throws
-
setIntInUserHash(to:
Asynchronousfield: userID: ) Declaration
Swift
func setIntInUserHash(to value: Int, field: NotificationType, userID: UUID) async throws
-
incrementIntInUserHash(field:
AsynchronoususerID: incAmount: ) Declaration
Swift
func incrementIntInUserHash(field: NotificationType, userID: UUID, incAmount: Int = 1) async throws
-
Declaration
Swift
func incrementAlertwordTwarrtInUserHash(word: String, userID: UUID, incAmount: Int = 1) async throws
-
Declaration
Swift
func incrementAlertwordPostInUserHash(word: String, userID: UUID, incAmount: Int = 1) async throws
-
setNextEventInUserHash(date:
AsynchronouseventID: userID: ) Declaration
Swift
func setNextEventInUserHash(date: Date?, eventID: UUID?, userID: UUID) async throws
-
setNextLFGInUserHash(date:
AsynchronouslfgID: userID: ) Declaration
Swift
func setNextLFGInUserHash(date: Date?, lfgID: UUID?, userID: UUID) async throws
-
Declaration
Swift
static var hashtagsRedisKey: RedisKey { get }
-
getHashtags(matching:
Asynchronous) Declaration
Swift
func getHashtags(matching: String) async throws -> [String]
-
addHashtags(_:
Asynchronous) Declaration
Swift
func addHashtags(_ hashtags: Set<String>) async throws
-
Declaration
Swift
static var alertwordsRedisKey: RedisKey { get }
-
Declaration
Swift
func getAlertwordUsersRedisKey(_ word: String) -> RedisKey
-
getAllAlertwords()
AsynchronousDeclaration
Swift
func getAllAlertwords() async throws -> Set<String>
-
addAlertword(_:
AsynchronoususerID: ) Declaration
Swift
func addAlertword(_ word: String, userID: UUID) async throws
-
removeAlertword(_:
Asynchronous) Declaration
Swift
func removeAlertword(_ word: String) async throws
-
removeUserAlertword(_:
AsynchronoususerID: ) Declaration
Swift
func removeUserAlertword(_ word: String, userID: UUID) async throws
-
getUsersForAlertword(_:
Asynchronous) Declaration
Swift
func getUsersForAlertword(_ word: String) async throws -> [UUID]
-
Declaration
Swift
static var activeAnnouncementRedisKey: RedisKey { get }
-
getActiveAnnouncementIDs()
AsynchronousDeclaration
Swift
func getActiveAnnouncementIDs() async throws -> [Int]?
-
setActiveAnnouncementIDs(_:
Asynchronous) Declaration
Swift
func setActiveAnnouncementIDs(_ ids: [Int]) async throws
-
resetActiveAnnouncementIDs()
AsynchronousDeclaration
Swift
func resetActiveAnnouncementIDs() async throws
-
getChatUnreadCounts(userID:
Asynchronousinbox: ) Declaration
Swift
func getChatUnreadCounts(userID: UUID, inbox: MailInbox) async throws -> (Int, Int)
-
getChatUnreadCount(_:
Asynchronousfor: in: ) Declaration
Swift
func getChatUnreadCount(_ chatID: UUID, for userID: UUID, in inbox: MailInbox) async throws -> Int?
-
getUnreadChats(userID:
Asynchronousinbox: ) Declaration
Swift
func getUnreadChats(userID: UUID, inbox: MailInbox) async throws -> [UUID]
-
markChatRead(type:
Asynchronousin: userID: ) Declaration
Swift
func markChatRead(type: NotificationType, in inbox: MailInbox? = nil, userID: UUID) async throws
-
markChatRead(_:
Asynchronousin: for: ) Declaration
Swift
func markChatRead(_ fezID: UUID, in inbox: MailInbox, for userID: UUID) async throws
-
userAddedToChat(chatID:
AsynchronoususerID: inbox: ) Declaration
Swift
func userAddedToChat(chatID: UUID, userID: UUID, inbox: MailInbox) async throws
-
newUnreadMessage(chatID:
AsynchronoususerID: inbox: ) Declaration
Swift
func newUnreadMessage(chatID: UUID, userID: UUID, inbox: MailInbox) async throws
-
deletedUnreadMessage(msgID:
AsynchronoususerID: inbox: ) Declaration
Swift
func deletedUnreadMessage(msgID: UUID, userID: UUID, inbox: MailInbox) async throws
-
markLFGDeleted(msgID:
AsynchronoususerID: ) Declaration
Swift
func markLFGDeleted(msgID: UUID, userID: UUID) async throws
-
addBlockedUsers(_:
AsynchronousblockedBy: ) Declaration
Swift
func addBlockedUsers(_ blockedUsers: [UUID], blockedBy requester: UUID) async throws
-
removeBlockedUsers(_:
AsynchronousblockedBy: ) Declaration
Swift
func removeBlockedUsers(_ blockedUsers: [UUID], blockedBy requester: UUID) async throws
-
getBlocks(for:
Asynchronous) Declaration
Swift
func getBlocks(for userUUID: UUID) async throws -> [UUID]
-
readSetting(_:
Asynchronous) Declaration
Swift
func readSetting(_ field: String) async throws -> RESPValue
-
writeSetting(_:
Asynchronousvalue: ) Declaration
Swift
func writeSetting(_ field: String, value: RESPValue) async throws -> Bool
-
setChatUnreadCount(_:
AsynchronouschatID: userID: inbox: ) Declaration
Swift
func setChatUnreadCount(_ value: Int, chatID: UUID, userID: UUID, inbox: MailInbox) async throws