You are not logged in Log in Join
You are here: Home » Members » Toby Dickenson » cache » 3 » cache.diff » View File

Log in
Name

Password

 

cache.diff

File details
Size
8 K
File type
text/plain

File contents

Index: lib/Components/BTree/BTree.c
===================================================================
RCS file: /home/cvs/development/external/Zope2/lib/Components/BTree/BTree.c,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -c -4 -r1.2 -r1.2.2.1
*** lib/Components/BTree/BTree.c	9 Jan 2002 14:25:28 -0000	1.2
--- lib/Components/BTree/BTree.c	25 Jan 2002 15:05:48 -0000	1.2.2.1
***************
*** 1176,1184 ****
  	  DECREF_VALUE(self->data[i].value);
  	}
        if(HasInstDict(self) && (dict=INSTANCE_DICT(self))) PyDict_Clear(dict);
        self->len=0;
!       self->state=cPersistent_GHOST_STATE;
      }
  
    Py_INCREF(Py_None);
    return Py_None;
--- 1176,1184 ----
  	  DECREF_VALUE(self->data[i].value);
  	}
        if(HasInstDict(self) && (dict=INSTANCE_DICT(self))) PyDict_Clear(dict);
        self->len=0;
!       PER_GHOSTIFY(self);
      }
  
    Py_INCREF(Py_None);
    return Py_None;
***************
*** 1234,1242 ****
        PyObject *dict;
  
        if(_BTree_clear(self) < 0) return NULL;
        if(HasInstDict(self) && (dict=INSTANCE_DICT(self))) PyDict_Clear(dict);
!       self->state=cPersistent_GHOST_STATE;
      }
  
    Py_INCREF(Py_None);
    return Py_None;
--- 1234,1242 ----
        PyObject *dict;
  
        if(_BTree_clear(self) < 0) return NULL;
        if(HasInstDict(self) && (dict=INSTANCE_DICT(self))) PyDict_Clear(dict);
!       PER_GHOSTIFY(self);
      }
  
    Py_INCREF(Py_None);
    return Py_None;
Index: lib/Components/BTree/intSet.c
===================================================================
RCS file: /home/cvs/development/external/Zope2/lib/Components/BTree/intSet.c,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -c -4 -r1.2 -r1.2.2.1
*** lib/Components/BTree/intSet.c	9 Jan 2002 14:25:29 -0000	1.2
--- lib/Components/BTree/intSet.c	25 Jan 2002 15:05:48 -0000	1.2.2.1
***************
*** 439,447 ****
    if(self->state==cPersistent_UPTODATE_STATE 
       && HasInstDict(self) && (dict=INSTANCE_DICT(self)))
      {
        PyDict_Clear(dict);
!       self->state=cPersistent_GHOST_STATE;
      }
  
    Py_INCREF(Py_None);
    return Py_None;
--- 439,447 ----
    if(self->state==cPersistent_UPTODATE_STATE 
       && HasInstDict(self) && (dict=INSTANCE_DICT(self)))
      {
        PyDict_Clear(dict);
!       PER_GHOSTIFY(self);
      }
  
    Py_INCREF(Py_None);
    return Py_None;
Index: lib/Components/ExtensionClass/src/Record.c
===================================================================
RCS file: /home/cvs/development/external/Zope2/lib/Components/ExtensionClass/src/Record.c,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -c -4 -r1.2 -r1.2.2.1
*** lib/Components/ExtensionClass/src/Record.c	9 Jan 2002 14:25:29 -0000	1.2
--- lib/Components/ExtensionClass/src/Record.c	25 Jan 2002 15:05:48 -0000	1.2.2.1
***************
*** 220,228 ****
  {
    Record_deal(self);
    self->schema=NULL;
    self->data=NULL;
!   self->state=cPersistent_GHOST_STATE;
    Py_INCREF(Py_None);
    return Py_None;
  }
  #endif
--- 220,228 ----
  {
    Record_deal(self);
    self->schema=NULL;
    self->data=NULL;
!   PER_GHOSTIFY(self);
    Py_INCREF(Py_None);
    return Py_None;
  }
  #endif
Index: lib/python/BTrees/BTreeTemplate.c
===================================================================
RCS file: /home/cvs/development/external/Zope2/lib/python/BTrees/BTreeTemplate.c,v
retrieving revision 1.1.1.2
retrieving revision 1.1.1.2.8.1
diff -c -4 -r1.1.1.2 -r1.1.1.2.8.1
*** lib/python/BTrees/BTreeTemplate.c	10 Sep 2001 14:55:08 -0000	1.1.1.2
--- lib/python/BTrees/BTreeTemplate.c	25 Jan 2002 15:05:48 -0000	1.1.1.2.8.1
***************
*** 643,651 ****
  {
    if (self->state==cPersistent_UPTODATE_STATE && self->jar)
      {
        if (_BTree_clear(self) < 0) return NULL;
!       self->state=cPersistent_GHOST_STATE;
      }
  
    Py_INCREF(Py_None);
    return Py_None;
--- 643,651 ----
  {
    if (self->state==cPersistent_UPTODATE_STATE && self->jar)
      {
        if (_BTree_clear(self) < 0) return NULL;
!       PER_GHOSTIFY(self);
      }
  
    Py_INCREF(Py_None);
    return Py_None;
Index: lib/python/BTrees/BucketTemplate.c
===================================================================
RCS file: /home/cvs/development/external/Zope2/lib/python/BTrees/BucketTemplate.c,v
retrieving revision 1.1.1.2
retrieving revision 1.1.1.2.8.1
diff -c -4 -r1.1.1.2 -r1.1.1.2.8.1
*** lib/python/BTrees/BucketTemplate.c	10 Sep 2001 14:55:08 -0000	1.1.1.2
--- lib/python/BTrees/BucketTemplate.c	25 Jan 2002 15:05:48 -0000	1.1.1.2.8.1
***************
*** 859,867 ****
  {
    if (self->state==cPersistent_UPTODATE_STATE && self->jar)
      {
        if (_bucket_clear(self) < 0) return NULL;
!       self->state=cPersistent_GHOST_STATE;
      }
  
    Py_INCREF(Py_None);
    return Py_None;
--- 859,867 ----
  {
    if (self->state==cPersistent_UPTODATE_STATE && self->jar)
      {
        if (_bucket_clear(self) < 0) return NULL;
!       PER_GHOSTIFY(self);
      }
  
    Py_INCREF(Py_None);
    return Py_None;
Index: lib/python/ZODB/Connection.py
===================================================================
RCS file: /home/cvs/development/external/Zope2/lib/python/ZODB/Connection.py,v
retrieving revision 1.7
retrieving revision 1.7.8.7
diff -c -4 -r1.7 -r1.7.8.7
*** lib/python/ZODB/Connection.py	10 Sep 2001 15:32:28 -0000	1.7
--- lib/python/ZODB/Connection.py	28 Jan 2002 11:44:45 -0000	1.7.8.7
***************
*** 136,149 ****
--- 136,165 ----
                   cache_deactivate_after=60):
          """Create a new Connection"""
          self._version=version
          self._cache=cache=PickleCache(self, cache_size, cache_deactivate_after)
+         if version:
+             # Caches for versions end up empty if the version
+             # is not used for a while. Non-version caches
+             # keep their content indefinitely.
+             self._cache.cache_drain_resistance = 100
          self._incrgc=self.cacheGC=cache.incrgc
          self._invalidated=d={}
          self._invalid=d.has_key
          self._committed=[]
          self._code_timestamp = global_code_timestamp
  
+     def _cache_items(self):
+         # find all items on the lru list
+         items = self._cache.lru_items()
+         # fine everything. some on the lru list, some not
+         everything = self._cache.cache_data
+         # remove those items that are on the lru list
+         for k,v in items:
+             del everything[k]
+         # return a list of [ghosts....not recently used.....recently used]
+         return everything.items() + items
+ 
      def __repr__(self):
          if self._version:
              ver = ' (in version %s)' % `self._version`
          else:
***************
*** 492,502 ****
          cache_get=cache.get
          for oid in creating:
              o=cache_get(oid, None)
              if o is not None:
                  del o._p_jar
                  del o._p_oid
-                 del cache[oid]
  
      #XXX
  
      def db(self): return self._db
--- 508,518 ----
          cache_get=cache.get
          for oid in creating:
              o=cache_get(oid, None)
              if o is not None:
+                 del cache[oid]
                  del o._p_jar
                  del o._p_oid
  
      #XXX
  
      def db(self): return self._db
Index: lib/python/ZODB/DB.py
===================================================================
RCS file: /home/cvs/development/external/Zope2/lib/python/ZODB/DB.py,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -c -4 -r1.4 -r1.4.2.1
*** lib/python/ZODB/DB.py       25 Jan 2002 14:50:29 -0000      1.4
--- lib/python/ZODB/DB.py       25 Jan 2002 17:24:51 -0000      1.4.2.1
***************
*** 240,248 ****
          conn_no = [0]  # A mutable reference to a counter
          def f(con, detail=detail, rc=sys.getrefcount, conn_no=conn_no):
              conn_no[0] = conn_no[0] + 1
              cn = conn_no[0]
!             for oid, ob in con._cache.items():
                  id=''
                  if hasattr(ob,'__dict__'):
                      d=ob.__dict__
                      if d.has_key('id'):
--- 240,248 ----
          conn_no = [0]  # A mutable reference to a counter
          def f(con, detail=detail, rc=sys.getrefcount, conn_no=conn_no):
              conn_no[0] = conn_no[0] + 1
              cn = conn_no[0]
!             for oid, ob in con._cache_items():
                  id=''
                  if hasattr(ob,'__dict__'):
                      d=ob.__dict__
                      if d.has_key('id'):