firebase realtime database update view count immediately after reading it

I have this firebase realtime database

{
  "posts" : {
    "-Mt8iPsoxOk2rXwfjVKF" : {
      "date" : 1641914412858,
      "user_name" : "aaaa",
      "post_id" : "CYjxpgaMz9P",
      "view_count" : 2
    },
    "-Mt8iPvXA4ALKqSX0dH-" : {
      "date" : 1641914413011,
      "user_name" : "bbb",
      "post_id" : "CDzbKl0lIK-",
      "view_count" : 0
    },
    "-Mt8iPxfJOax_U6TjYov" : {
      "date" : 1641914413155,
      "user_name" : "ccc",
      "post_id" : "B7NZYOnA_NG",
      "view_count" : 0
    }
  }
}

I want to update views count immediately after reading the post , I tried to use this method but the problem with it that we have a lot of reads on a single second so it takes time to read then update the view , we need to limit the post for 5 views only then delete it , but we can't do that because in a singles second we have more then 10 views each view takes time to update the view count so the next user will continue reading the same post even if the post is beyond views limits.

[recentPostsQuery observeSingleEventOfType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot * _Nonnull snapshot) {
    
    self->user_name = snapshot.children.allObjects.firstObject.value[@"user_name"];
    self->post_key  = snapshot.children.allObjects.firstObject.key;

    [[[[self.ref child:@"posts"]child:self->post_key]child:@"view_count"]setValue:[FIRServerValue increment:@1]];
    
}];

In a massively multi-user environment, where all users are accessing the data directly, there is no way to enforce a hard limit like the one you are describing.

If the hard limit is a hard requirement for your application, consider routing all access to the data to a server-side component, which can then enforce this requirement. You could consider using Cloud Functions or Cloud Run for this, if you don't have a server yet.