How to caching the vb object in application scope 
Author Message
 How to caching the vb object in application scope

Hi everyone,

Because for i really need caching the user object in application variable, when i
login my web application and add it to my application scope and later i can use
it check its access control rights, it is important to me.
I also know that set the Non-Agile component in application is not advisability,
So i make a ADO recordsets in Application scope to store my user obj like this:

Sub Application_OnStart
        ' ========================================================================
        Set rsUser = Server.CreateObject("ADODB.Recordset")
        rsUser.CursorLocation = 3  'adUseClient
        rsUser.Fields.Append "ID", 200,50,adFldMayBeNull
        rsUser.Fields.Append "user_obj", 12,,adFldMayBeNull  
        rsUser.Open
        set Application("user_obj") = rsUser
        ' ========================================================================
End Sub

and use this in my login process asp file like this:

        ' ========================================================================
        Dim uobj
        set uobj = Server.CreateObject("AccessControl.User")

        Application("user_obj").MoveFirst
        Application("user_obj").Find "ID='" & uid & ":" & sid & "'"

        if Application("user_obj").Eof Then
                err.Clear
                uobj.UserID = cstr(uid)
                uobj.SchoolID = cstr(sid)
                uobj.Populate
                Call CheckSystemError(err)
                Application.Lock
                        Application("user_obj").AddNew
                        Application("user_obj").Fields("ID").Value = uid & ":" &
sid
                        Application("user_obj").Fields("user_obj").Value = uobj
                        Application("user_obj").Update
                Application.UnLock
        End if  

        set uobj = Application("user_obj").Fields("user_obj").Value
        ' ========================================================================

then i can use my user obj is every module in this way instead of populate from
database when i need it.

my user object is a apartment-threaded(not FTM), But my ado recordset object is a
Free-threaded and also a disconnected recordset. i think it is agile component.

I do not sure this way can have serious pitfalls, Because if my component caches
interface pointers, those pointers must themselves be agile, or must be stroed in
the COM Global Interface Table, otherwiase  worse effect performance.

I still want to look some good ideal how to serialization a object property to a
xml string or other variable to store my object.

Any ideal will be appreciate!

Thanx,      

 Liu Yuan



Wed, 12 Nov 2003 13:55:53 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Passing VB OLE objects in the Application object (IIS3, VB5, ASP, VBS)

2. VB Variable and Object Scope Questions

3. Object caching using session object

4. Sharing Object and it's static data between application VB applications

5. Sharing Object and it's static data between application VB applications

6. Sharing Object and it's static data between application VB applications

7. Using application Scope Arrays

8. Assigning values to Application scope variables from a recordset fails

9. ASP components and application scope

10. COM Component on Application Scope

11. Print via VB-Script ActiveX-Control in VB-Application

12. Scope of database and workspace objects?

 

 
Powered by phpBB® Forum Software