我有一个app
有users
和这些users
相关的几乎每个部分。例如,用户与B是朋友。A和B可以互相阻止或被阻止。A和B可以互相发送媒体等,A可以设置你的个人资料照片隐私隐藏。他们根据各自的信息(个人资料照片、共享媒体等)来查看对方的信息。根据他们之间的关系,privacy status
可能总是随着任何其他人的互动而改变。所以看起来数据是动态的,必须保持动态,不能被缓存(在我看来)。
我正在使用laravelfriendship status
从block status
中收集media relationship
,我有复杂的relationship data
用elequent model
,data
和DB
等来获取queries
。几乎每一个查询,我都用一次点击来收集数据。所以当user data
或user infos
中的任何一个改变为friends's
时。这些friendship informations
将从friend
的单个或多个点改变。因此,当我尝试从friendship data
(user
或one hit collected data
)获取data
时,它将不是真正的更新data
。
我想用图片展示我的例子并扩展我的问题。
在示例i(cached data
)中,有一个包含cache driver
和redis
的..
。当任何朋友像(data
,UserApp
对我,friend list
)那样与我交互,或者当我与他们交互(my friend's infos
,diffrent views
,block me
等)时,数据和视图都会动态地变化,而不会刷新。但是这个页面是sent media
的,我不想为每个hide their profile photo to everyone
运行block them
。在我的remove from friendship
中也有同样的sent media
类型,如果refreshable
有很多query
的话,我想这些refresh
会更贵。什么是正确的方法来减轻我的负担。如果你给我指路…我可以向前走。提前谢谢..
frienship查询数据示例
[
{
"id": 44,
"name": "Name1",
"surname": "Surname2",
"country": null,
"town": null,
"email": null,
"phone": "5559933939",
"photo": "/App/Users/Profile/ProfilePictures/1/User_1~Time_1510076458061.jpg",
"profession": null,
"dob": "2011-10-29",
"gender": 1,
"statusTitle": "my status title",
"rank": 1,
"isPremium": 0,
"isAllowedNotifications": 1,
"isAllowedSmsNotifications": 0,
"profilePhotoPrivacyStatus": "2",
"statusTitlePrivacyStatus": "1",
"playerID": null,
"userID": 29,
"friendID": 1,
"friendshipRequester": null,
"friendshipStatus": 3,
"isBlocked": 0,
"isAllowedToTakeReturnMedia": 0,
"isSilenced": 0,
"isMediaActiveAndChangable": 1,
"isSeen": 0,
"isCalled": 0,
"myStatusForFriend": 1,
"isBlockedByFriend": 0,
"fromMeVideoCount": 1,
"toMeVideoCount": 0,
},
{
"id": 53,
"name": "Name2",
"surname": "Surname2",
"country": null,
"town": null,
"email": null,
"phone": "5559933123",
"photo": "/App/Users/Profile/ProfilePictures/2/User_2~Time_1511690217936.jpg",
"profession": null,
"dob": "1992-10-27",
"gender": 2,
"statusTitle": "Hey! lets suprise me..",
"rank": 1,
"isPremium": 0,
"isAllowedNotifications": 1,
"isAllowedSmsNotifications": 0,
"profilePhotoPrivacyStatus": null,
"statusTitlePrivacyStatus": null,
"playerID": "asda9d-12asda-4bd6-a882-sgdfadasd",
"userID": 29,
"friendID": 2,
"friendshipRequester": 2,
"friendshipStatus": 3,
"isBlocked": 0,
"isAllowedToTakeReturnMedia": 1,
"isSilenced": 0,
"isMediaActiveAndChangable": 1,
"isSeen": 0,
"isCalled": 0,
"myStatusForFriend": 3,
"isBlockedByFriend": 0,
"fromMeVideoCount": 21,
"toMeVideoCount": 0,
最佳答案
我以前也做过类似的事情。我的解决方案是在写入更新时擦除缓存。
例如,用户A发送数据->擦除用户A的缓存信息->写入数据。
用户B读取用户A数据->缓存从数据库中再次填充。
关于php - 如何使用laravel或更多全局缓存动态数据必须是动态缓存的逻辑,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47517537/