Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
908effce
Commit
908effce
authored
Oct 23, 2001
by
matt@zope.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated Transience for objects
parent
6de31994
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
8 deletions
+14
-8
lib/python/Products/Transience/Transience.py
lib/python/Products/Transience/Transience.py
+14
-8
No files found.
lib/python/Products/Transience/Transience.py
View file @
908effce
...
...
@@ -85,10 +85,10 @@
"""
Core session tracking SessionData class.
$Id: Transience.py,v 1.
4 2001/10/22 20:00:34
matt Exp $
$Id: Transience.py,v 1.
5 2001/10/23 19:17:27
matt Exp $
"""
__version__
=
'$Revision: 1.
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
5
$'
[
11
:
-
2
]
import
Globals
from
Globals
import
HTMLFile
,
MessageDialog
...
...
@@ -107,6 +107,9 @@ import time
_notfound
=
[]
_marker
=
[]
WRITEGRANULARITY
=
30
# Timing granularity for write clustering, in seconds
time
=
time
.
time
# permissions
ADD_DATAMGR_PERM
=
'Add Transient Object Container'
CHANGE_DATAMGR_PERM
=
'Change Transient Object Containers'
...
...
@@ -229,6 +232,8 @@ class TransientObjectContainer(SimpleItem):
self
[
key
]
=
item
self
.
notifyAdd
(
item
)
return
item
...
...
@@ -378,7 +383,7 @@ class TransientObjectContainer(SimpleItem):
numbuckets
=
int
(
math
.
floor
(
t_secs
/
r_secs
))
or
1
l
=
[]
i
=
0
now
=
int
(
time
.
time
())
now
=
int
(
time
())
for
x
in
range
(
numbuckets
):
dump_after
=
now
+
i
c
=
self
.
_ctype
()
...
...
@@ -394,7 +399,7 @@ class TransientObjectContainer(SimpleItem):
b
,
dump_after
=
self
.
_ring
.
_data
[
0
]
return
b
index
=
self
.
_ring
.
_index
now
=
int
(
time
.
time
())
now
=
int
(
time
())
i
=
self
.
_timeout_secs
# expire all buckets in the ring which have a dump_after time that
# is before now, turning the ring as many turns as necessary to
...
...
@@ -465,13 +470,13 @@ class TransientObjectContainer(SimpleItem):
if
b
is
None
:
# this is a new key
index
[
k
]
=
current
self
.
notifyAdd
(
v
)
elif
b
is
not
current
:
# this is an old key that isn't in the current bucket.
del
b
[
k
]
# delete it from the old bucket
index
[
k
]
=
current
# change the value
current
[
k
]
=
v
v
.
setLastAccessed
()
def
__getitem__
(
self
,
k
):
current
=
self
.
_getCurrentBucket
()
...
...
@@ -484,6 +489,7 @@ class TransientObjectContainer(SimpleItem):
# we accessed the object, so it should become current.
index
[
k
]
=
current
# change the index to the current bucket.
current
[
k
]
=
v
# add the value to the current bucket.
v
.
setLastAccessed
()
del
b
[
k
]
# delete the item from the old bucket.
return
v
...
...
@@ -592,12 +598,12 @@ class TransientObject(Persistent, Implicit):
# Initialzer
#
def
__init__
(
self
,
id
,
parent
=
None
,
time
=
time
.
time
):
def
__init__
(
self
,
id
,
parent
=
None
):
self
.
id
=
id
self
.
_parent
=
parent
self
.
_container
=
{}
self
.
_created
=
self
.
_last_accessed
=
time
()
self
.
_timergranularity
=
30
# timer granularity for last accessed
self
.
_timergranularity
=
WRITEGRANULARITY
# timer granularity
# -----------------------------------------------------------------
...
...
@@ -619,7 +625,7 @@ class TransientObject(Persistent, Implicit):
def
getLastAccessed
(
self
):
return
self
.
_last_accessed
def
setLastAccessed
(
self
,
time
=
time
.
time
):
def
setLastAccessed
(
self
):
# check to see if the last_accessed time is too recent, and avoid
# setting if so, to cut down on heavy writes
t
=
time
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment