locked
Session -accessible by alle users RRS feed

  • Question

  • User1519416827 posted

    We have an intranet site generating a calendar from Exchange, where alle users appointments are shown.

    At startup - or refresh - the page queries Exhange and fetches all appointments (wrapped in a class called nptAppointment)

    Alle the appointments are combined in a List(of nptAppointment) which is the stored as a session variable to avoid load on the exchange server when users are browsing between views.

    Code as folllows:

     Protected Sub FetchAppointmentData(ByVal dag As Date)
    
            'Get users
            Dim users As List(Of String) = GetViewableUsersEmail()
            Dim AllUsersAppointments As New List(Of nptAppointment)
    
            'For each user, get their appointments for the time period
            For Each usr In users
                Dim us As nptAppointment = GetNPTuser(usr)
                Dim UsersAppointments As New List(Of nptAppointment)
    
    
                UsersAppointments = GetAppointmentsForUser(usr, dag.AddDays(CacheDaysFrom), dag.AddDays(CacheDaysTo))
    
                For Each aps As nptAppointment In UsersAppointments
                    AllUsersAppointments.Add(aps)
                Next
    
    
    
            Next
    
    
    
            'save the complete appointment list in a session
    
            Session("AllUsersAppointments") = AllUsersAppointments
    
        End Sub

     

    Now it seems, that the constant refreshing of pages is a burden to the exchange server.

    I could rewrite and store all the appointments in an SQL-database, but would like to keep this approach and store the AllUsersAppointments object in a way so all users can access it - then update it each 15 minutes or so.

    What I'm looking for is something similar to a Session, but accessible for all users.

     

    Is this feasible, or does anyone have another solution for sharing the AllUsersAppointments.

     

    In advance: Thank You

     

    Monday, April 15, 2013 8:10 AM

Answers

  • User281315223 posted

    You may want to consider using Cache storage instead of the Session. 

    The Session is typically used for storage on a user-by-user basis, however the Cache is actually Application-level, allowing it to be accessed by multiple users within a single Application (this of course depends on the environment you are using, such as a Web Farm etc.)

    Syntactically, they are very similar in usage : 

    //Cache Example (Fully Qualified)
    System.Web.HttpContext.Current.Cache["Key"] = "Value";
    //Session Example
    Session["Key"] = "Value";



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 15, 2013 8:26 AM

All replies

  • User281315223 posted

    You may want to consider using Cache storage instead of the Session. 

    The Session is typically used for storage on a user-by-user basis, however the Cache is actually Application-level, allowing it to be accessed by multiple users within a single Application (this of course depends on the environment you are using, such as a Web Farm etc.)

    Syntactically, they are very similar in usage : 

    //Cache Example (Fully Qualified)
    System.Web.HttpContext.Current.Cache["Key"] = "Value";
    //Session Example
    Session["Key"] = "Value";



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, April 15, 2013 8:26 AM
  • User2117486576 posted

    As an alternative or if you have a web farm or load balancer, you could use a no sql database like redis.

    http://redis.io/

    Monday, April 15, 2013 8:29 AM