Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8609477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:53:19+00:00 2026-06-12T03:53:19+00:00

I have a simple followers/following system set up within my app. What would be

  • 0

I have a simple followers/following system set up within my app.

What would be the best way to store a complete array of ‘users following’ during a session so that I don’t have to query the database multiple times throughout.

To clarify: When a user logs in once they have been authorized I query the database, get a full list of users that the logged in user is following and ultimately store it as a JavaScript variable. This way throughout the site, as the user navigates around I can constantly check the following status against any other user they may come across.

This query is only performed once when the user loads the full page, while navigating around it is not repeated.

This works well for javascript generated content i.e user hovercards etc…

However I would like to store this array (of only userid’s) in PHP itself so that I can prevent further queries to the following table while generating content server side that requires a ‘follower/following’ check to be performed.

What would be the best way to do this?

Please bare in mind that the results are cached in memcached but if I can avoid any lookups at all and have a consistent array to check against that would be great.

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T03:53:20+00:00Added an answer on June 12, 2026 at 3:53 am

    So let me get this right, you want to store this list so it isn’t queried on each page?

    First I would recommend you only perform this query on pages that need this data and second I would say that on these pages you don’t try this.

    Imagine a user stops following or starts following. Some complex cache calculator or event bubbler programmed into your own PHP app to purge the foreign session of data (which is bad, the user has access to data that is not their own, a session infact) could be tiedious with security and performance.

    The better thing to do is to perform the query again for each new page. This would be much easier, probably more performant and wouldn’t be micro-optimising.

    Edit

    If you are picking out 10k rows on one page then you might be doing something wrong. You might be looking at it from the wrong perspective.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have the following set up in my web app, where on the
I have a simple JSF web app as follows. The Java class contains: private
I made a simple following-follower system with php(pdo) and mysql. My problem is, Let's
I have a system set up where a ContextMenu hierarchy is populated dynamically using
I have a simple for loop followed by a simple if statement: for airport
In Scala, if I have a simple class as follows: val calc = actor
i have a simple if condition as follows... $site = new-object Microsoft.SharePoint.SPSite($url) $sitelists =
I have a simple LINQ query on ADO.NET Entity Framework as follows var result
I have a simple table in Sybase, let's say it looks as follows: CREATE
Strange issue I am having with my MVC3 project. I have followed a simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.