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
60d04a03
Commit
60d04a03
authored
Nov 03, 2003
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lots of cleanup; remove archaic BoboPOS 2 support
parent
537cb142
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
95 deletions
+47
-95
lib/python/App/CacheManager.py
lib/python/App/CacheManager.py
+47
-95
No files found.
lib/python/App/CacheManager.py
View file @
60d04a03
...
@@ -10,104 +10,82 @@
...
@@ -10,104 +10,82 @@
# FOR A PARTICULAR PURPOSE
# FOR A PARTICULAR PURPOSE
#
#
##############################################################################
##############################################################################
__doc__
=
'''Cache management support
'''Cache management support.
This class is mixed into the database manager in App.ApplicationManager.
$Id: CacheManager.py,v 1.2
8 2003/11/03 16:40:37
fdrake Exp $'''
$Id: CacheManager.py,v 1.2
9 2003/11/03 19:08:44
fdrake Exp $'''
__version__
=
'$Revision: 1.2
8
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.2
9
$'
[
11
:
-
2
]
import
Globals
,
time
,
sys
import
time
import
Globals
from
DateTime
import
DateTime
from
DateTime
import
DateTime
class
CacheManager
:
class
CacheManager
:
"""Cache management mix-in
"""Cache management mix-in
"""
"""
_cache_age
=
60
_cache_age
=
60
_vcache_age
=
60
_vcache_age
=
60
_history_length
=
3600
# Seconds
_history_length
=
3600
# Seconds
manage_cacheParameters
=
Globals
.
DTMLFile
(
'dtml/cacheParameters'
,
globals
())
manage_cacheParameters
=
Globals
.
DTMLFile
(
'dtml/cacheParameters'
,
manage_cacheGC
=
Globals
.
DTMLFile
(
'dtml/cacheGC'
,
globals
())
globals
())
manage_cacheGC
=
Globals
.
DTMLFile
(
'dtml/cacheGC'
,
globals
())
transparent_bar
=
Globals
.
ImageFile
(
'www/transparent_bar.gif'
,
globals
())
transparent_bar
=
Globals
.
ImageFile
(
'www/transparent_bar.gif'
,
globals
())
store_bar
=
Globals
.
ImageFile
(
'www/store_bar.gif'
,
globals
())
store_bar
=
Globals
.
ImageFile
(
'www/store_bar.gif'
,
globals
())
load_bar
=
Globals
.
ImageFile
(
'www/load_bar.gif'
,
globals
())
load_bar
=
Globals
.
ImageFile
(
'www/load_bar.gif'
,
globals
())
def
_getDB
(
self
):
return
self
.
_p_jar
.
db
()
def
_inVersion
(
self
):
return
self
.
_p_jar
.
getVersion
()
and
True
or
False
def
cache_length
(
self
):
def
cache_length
(
self
):
try
:
db
=
self
.
_p_jar
.
db
()
return
self
.
_getDB
().
cacheSize
()
except
:
# BoboPOS2
return
len
(
Globals
.
Bobobase
.
_jar
.
cache
)
else
:
return
db
.
cacheSize
()
def
cache_detail_length
(
self
):
def
cache_detail_length
(
self
):
try
:
db
=
self
.
_p_jar
.
db
()
return
self
.
_getDB
().
cacheDetailSize
()
except
:
return
()
else
:
return
db
.
cacheDetailSize
()
def
database_size
(
self
):
def
database_size
(
self
):
try
:
db
=
self
.
_p_jar
.
db
()
return
self
.
_getDB
().
objectCount
()
except
:
# BoboPOS2
return
len
(
Globals
.
Bobobase
.
_jar
.
db
.
index
)
*
4
else
:
return
db
.
objectCount
()
def
cache_age
(
self
):
def
cache_age
(
self
):
try
:
if
self
.
_inVersion
():
if
self
.
_p_jar
.
getVersion
():
return
self
.
_vcache_age
return
self
.
_vcache_age
else
:
except
:
pass
return
self
.
_cache_age
return
self
.
_cache_age
def
manage_cache_age
(
self
,
value
,
REQUEST
):
def
manage_cache_age
(
self
,
value
,
REQUEST
):
"set cache age"
"set cache age"
try
:
db
=
self
.
_getDB
()
v
=
self
.
_p_jar
.
getVersion
()
if
self
.
_inVersion
():
except
:
self
.
_vcache_age
=
value
# BoboPOS2:
db
.
setVersionCacheDeactivateAfter
(
value
)
if
self
.
_p_jar
.
db
is
not
Globals
.
Bobobase
.
_jar
.
db
:
raise
'Version Error'
,
(
'''You may not change the database cache age
while working in a <em>version</em>'''
)
self
.
_cache_age
=
Globals
.
Bobobase
.
_jar
.
cache
.
cache_age
=
value
else
:
else
:
if
v
:
self
.
_cache_age
=
value
self
.
_vcache_age
=
value
db
.
setCacheDeactivateAfter
(
value
)
self
.
_p_jar
.
db
().
setVersionCacheDeactivateAfter
(
value
)
else
:
self
.
_cache_age
=
value
self
.
_p_jar
.
db
().
setCacheDeactivateAfter
(
value
)
if
REQUEST
is
not
None
:
if
REQUEST
is
not
None
:
response
=
REQUEST
[
'RESPONSE'
]
response
=
REQUEST
[
'RESPONSE'
]
response
.
redirect
(
REQUEST
[
'URL1'
]
+
'/manage_cacheParameters'
)
response
.
redirect
(
REQUEST
[
'URL1'
]
+
'/manage_cacheParameters'
)
def
cache_size
(
self
):
def
cache_size
(
self
):
try
:
db
=
self
.
_getDB
()
if
self
.
_p_jar
.
get
Version
():
if
self
.
_in
Version
():
return
self
.
_p_jar
.
db
()
.
getVersionCacheSize
()
return
db
.
getVersionCacheSize
()
e
xcept
:
pass
e
lse
:
return
self
.
_p_jar
.
db
()
.
getCacheSize
()
return
db
.
getCacheSize
()
def
manage_cache_size
(
self
,
value
,
REQUEST
):
def
manage_cache_size
(
self
,
value
,
REQUEST
):
"set cache size"
"set cache size"
try
:
db
=
self
.
_getDB
()
v
=
self
.
_p_jar
.
getVersion
()
if
self
.
_inVersion
():
except
:
db
.
setVersionCacheSize
(
value
)
# BoboPOS2:
if
self
.
_p_jar
.
db
is
not
Globals
.
Bobobase
.
_jar
.
db
:
raise
'Version Error'
,
(
'''You may not change the database cache size
while working in a <em>version</em>'''
)
Globals
.
Bobobase
.
_jar
.
cache
.
cache_size
=
value
else
:
else
:
db
=
self
.
_p_jar
.
db
()
db
.
setCacheSize
(
value
)
if
v
:
db
.
setVersionCacheSize
(
value
)
else
:
db
.
setCacheSize
(
value
)
if
REQUEST
is
not
None
:
if
REQUEST
is
not
None
:
response
=
REQUEST
[
'RESPONSE'
]
response
=
REQUEST
[
'RESPONSE'
]
...
@@ -115,24 +93,7 @@ class CacheManager:
...
@@ -115,24 +93,7 @@ class CacheManager:
def
cacheStatistics
(
self
):
def
cacheStatistics
(
self
):
try
:
return
self
.
_p_jar
.
db
().
cacheStatistics
()
return
self
.
_getDB
().
cacheStatistics
()
except
:
pass
# BoboPOS 2
return
(
(
'Mean time since last access (minutes)'
,
"%.4g"
%
(
Globals
.
Bobobase
.
_jar
.
cache
.
cache_mean_age
/
60.0
)),
(
'Deallocation rate (objects/minute)'
,
"%.4g"
%
(
Globals
.
Bobobase
.
_jar
.
cache
.
cache_mean_deal
*
60
)),
(
'Deactivation rate (objects/minute)'
,
"%.4g"
%
(
Globals
.
Bobobase
.
_jar
.
cache
.
cache_mean_deac
*
60
)),
(
'Time of last cache garbage collection'
,
time
.
asctime
(
time
.
localtime
(
Globals
.
Bobobase
.
_jar
.
cache
.
cache_last_gc_time
))
),
)
# BoboPOS 2
# BoboPOS 2
def
cache_mean_age
(
self
):
def
cache_mean_age
(
self
):
...
@@ -153,11 +114,8 @@ class CacheManager:
...
@@ -153,11 +114,8 @@ class CacheManager:
def
manage_full_sweep
(
self
,
value
,
REQUEST
):
def
manage_full_sweep
(
self
,
value
,
REQUEST
):
"Perform a full sweep through the cache"
"Perform a full sweep through the cache"
try
:
db
=
self
.
_p_jar
.
db
()
db
=
self
.
_getDB
()
except
:
db
.
cacheFullSweep
(
value
)
# BoboPOS2
Globals
.
Bobobase
.
_jar
.
cache
.
full_sweep
(
value
)
else
:
db
.
cacheFullSweep
(
value
)
if
REQUEST
is
not
None
:
if
REQUEST
is
not
None
:
response
=
REQUEST
[
'RESPONSE'
]
response
=
REQUEST
[
'RESPONSE'
]
...
@@ -165,11 +123,7 @@ class CacheManager:
...
@@ -165,11 +123,7 @@ class CacheManager:
def
manage_minimize
(
self
,
value
=
1
,
REQUEST
=
None
):
def
manage_minimize
(
self
,
value
=
1
,
REQUEST
=
None
):
"Perform a full sweep through the cache"
"Perform a full sweep through the cache"
try
:
db
=
self
.
_p_jar
.
db
()
self
.
_getDB
().
cacheMinimize
(
value
)
except
:
# BoboPOS2
Globals
.
Bobobase
.
_jar
.
cache
.
minimize
(
value
)
else
:
db
.
cacheMinimize
(
value
)
if
REQUEST
is
not
None
:
if
REQUEST
is
not
None
:
response
=
REQUEST
[
'RESPONSE'
]
response
=
REQUEST
[
'RESPONSE'
]
...
@@ -184,8 +138,7 @@ class CacheManager:
...
@@ -184,8 +138,7 @@ class CacheManager:
Returns the name of the classes of the objects in the cache
Returns the name of the classes of the objects in the cache
and the number of objects in the cache for each class.
and the number of objects in the cache for each class.
"""
"""
db
=
self
.
_p_jar
.
db
()
detail
=
self
.
_getDB
().
cacheDetail
()
detail
=
db
.
cacheDetail
()
if
REQUEST
is
not
None
:
if
REQUEST
is
not
None
:
# format as text
# format as text
REQUEST
.
RESPONSE
.
setHeader
(
'Content-Type'
,
'text/plain'
)
REQUEST
.
RESPONSE
.
setHeader
(
'Content-Type'
,
'text/plain'
)
...
@@ -199,8 +152,7 @@ class CacheManager:
...
@@ -199,8 +152,7 @@ class CacheManager:
"""
"""
Returns information about each object in the cache.
Returns information about each object in the cache.
"""
"""
db
=
self
.
_p_jar
.
db
()
detail
=
self
.
_getDB
().
cacheExtremeDetail
()
detail
=
db
.
cacheExtremeDetail
()
if
REQUEST
is
not
None
:
if
REQUEST
is
not
None
:
# sort the list.
# sort the list.
lst
=
map
(
lambda
dict
:
((
dict
[
'conn_no'
],
dict
[
'oid'
]),
dict
),
lst
=
map
(
lambda
dict
:
((
dict
[
'conn_no'
],
dict
[
'oid'
]),
dict
),
...
@@ -233,7 +185,7 @@ class CacheManager:
...
@@ -233,7 +185,7 @@ class CacheManager:
return
detail
return
detail
def
_getActivityMonitor
(
self
):
def
_getActivityMonitor
(
self
):
db
=
self
.
_
p_jar
.
db
()
db
=
self
.
_
getDB
()
if
not
hasattr
(
db
,
'getActivityMonitor'
):
if
not
hasattr
(
db
,
'getActivityMonitor'
):
return
None
return
None
am
=
db
.
getActivityMonitor
()
am
=
db
.
getActivityMonitor
()
...
...
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