Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
c29f3af1
Commit
c29f3af1
authored
Jan 21, 2015
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace SplitMongo thread_cache usage with use of request_cache
parent
d7cf5d61
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
16 deletions
+11
-16
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
+11
-16
No files found.
common/lib/xmodule/xmodule/modulestore/split_mongo/split.py
View file @
c29f3af1
...
@@ -53,7 +53,6 @@ Representation:
...
@@ -53,7 +53,6 @@ Representation:
definition. Acts as a pseudo-object identifier.
definition. Acts as a pseudo-object identifier.
"""
"""
import
copy
import
copy
import
threading
import
datetime
import
datetime
import
hashlib
import
hashlib
import
logging
import
logging
...
@@ -618,10 +617,6 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
...
@@ -618,10 +617,6 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
self
.
db_connection
=
MongoConnection
(
**
doc_store_config
)
self
.
db_connection
=
MongoConnection
(
**
doc_store_config
)
self
.
db
=
self
.
db_connection
.
database
self
.
db
=
self
.
db_connection
.
database
# Code review question: How should I expire entries?
# _add_cache could use a lru mechanism to control the cache size?
self
.
thread_cache
=
threading
.
local
()
if
default_class
is
not
None
:
if
default_class
is
not
None
:
module_path
,
__
,
class_name
=
default_class
.
rpartition
(
'.'
)
module_path
,
__
,
class_name
=
default_class
.
rpartition
(
'.'
)
class_
=
getattr
(
import_module
(
module_path
),
class_name
)
class_
=
getattr
(
import_module
(
module_path
),
class_name
)
...
@@ -732,10 +727,10 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
...
@@ -732,10 +727,10 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
Find the descriptor cache for this course if it exists
Find the descriptor cache for this course if it exists
:param course_version_guid:
:param course_version_guid:
"""
"""
if
not
hasattr
(
self
.
thread_cache
,
'course_cache'
)
:
if
self
.
request_cache
is
None
:
self
.
thread_cache
.
course_cache
=
{}
return
None
system
=
self
.
thread_cache
.
course_cache
return
s
ystem
.
get
(
course_version_guid
)
return
s
elf
.
request_cache
.
data
.
setdefault
(
'course_cache'
,
{})
.
get
(
course_version_guid
)
def
_add_cache
(
self
,
course_version_guid
,
system
):
def
_add_cache
(
self
,
course_version_guid
,
system
):
"""
"""
...
@@ -743,9 +738,8 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
...
@@ -743,9 +738,8 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
:param course_version_guid:
:param course_version_guid:
:param system:
:param system:
"""
"""
if
not
hasattr
(
self
.
thread_cache
,
'course_cache'
):
if
self
.
request_cache
is
not
None
:
self
.
thread_cache
.
course_cache
=
{}
self
.
request_cache
.
data
.
setdefault
(
'course_cache'
,
{})[
course_version_guid
]
=
system
self
.
thread_cache
.
course_cache
[
course_version_guid
]
=
system
return
system
return
system
def
_clear_cache
(
self
,
course_version_guid
=
None
):
def
_clear_cache
(
self
,
course_version_guid
=
None
):
...
@@ -753,15 +747,16 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
...
@@ -753,15 +747,16 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase):
Should only be used by testing or something which implements transactional boundary semantics.
Should only be used by testing or something which implements transactional boundary semantics.
:param course_version_guid: if provided, clear only this entry
:param course_version_guid: if provided, clear only this entry
"""
"""
if
self
.
request_cache
is
None
:
return
if
course_version_guid
:
if
course_version_guid
:
if
not
hasattr
(
self
.
thread_cache
,
'course_cache'
):
self
.
thread_cache
.
course_cache
=
{}
try
:
try
:
del
self
.
thread_cache
.
course_cache
[
course_version_guid
]
del
self
.
request_cache
.
data
.
setdefault
(
'course_cache'
,
{})
[
course_version_guid
]
except
KeyError
:
except
KeyError
:
pass
pass
else
:
else
:
self
.
thread_cache
.
course_cache
=
{}
self
.
request_cache
.
data
[
'course_cache'
]
=
{}
def
_lookup_course
(
self
,
course_key
):
def
_lookup_course
(
self
,
course_key
):
'''
'''
...
...
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