remove discussion cache, which isn't used

This commit is contained in:
Chris Dodge
2013-04-05 15:27:50 -04:00
parent f84eaf01b8
commit e717244611
5 changed files with 12 additions and 74 deletions

View File

@@ -1,54 +0,0 @@
import logging
from django.core.cache import cache, get_cache
from datetime import datetime
def _get_discussion_cache():
return get_cache('mongo_metadata_inheritance')
def get_discussion_cache_key(course_id):
return 'discussion_items_{0}'.format(course_id)
def get_discussion_cache_entry(modulestore, course_id):
cache_entry = None
cache = _get_discussion_cache()
if cache is not None:
cache_entry = cache.get(get_discussion_cache_key(course_id), None)
# @todo: add expiry here
if cache_entry is None:
cache_entry = generate_discussion_cache_entry(modulestore, course_id)
return cache_entry.get('modules',[])
def generate_discussion_cache_entry(modulestore, course_id):
# make this a NOP for now. We have to figure out how to pickle the result set
return
components = course_id.split('/')
all_discussion_modules = modulestore.get_items(['i4x', components[0], components[1], 'discussion', None],
course_id=course_id)
cache = _get_discussion_cache()
entry = {'modules': all_discussion_modules, 'timestamp': datetime.now()}
if cache is not None:
cache.set(get_discussion_cache_key(course_id), entry)
return entry
def modulestore_update_signal_handler(modulestore = None, course_id = None, location = None, **kwargs):
"""called when there is an write event in our modulestore
"""
return
if location.category == 'discussion':
logging.debug('******* got modulestore update signal. Regenerating discussion cache for {0}'.format(course_id))
# refresh the cache entry if we've changed a discussion module
generate_discussion_cache_entry(modulestore, course_id)
def discussion_cache_register_for_updates(modulestore):
if modulestore.modulestore_update_signal is not None:
modulestore.modulestore_update_signal.connect(modulestore_update_signal_handler)

View File

@@ -40,10 +40,11 @@ class XMLEditingDescriptor(EditingDescriptor):
js = {'coffee': [resource_string(__name__, 'js/src/raw/edit/xml.coffee')]}
js_module_name = "XMLEditingDescriptor"
class MetadataOnlyEditingDescriptor(EditingDescriptor):
"""
Module that provides a raw editing view of its data as XML. It does not perform
any validation of its definition
Module which only provides an editing interface for the metadata, it does
not expose a UI for editing the module data
"""
js = {'coffee': [resource_string(__name__, 'js/src/raw/edit/metadata-only.coffee')]}
@@ -51,6 +52,7 @@ class MetadataOnlyEditingDescriptor(EditingDescriptor):
mako_template = "widgets/metadata-only-edit.html"
class JSONEditingDescriptor(EditingDescriptor):
"""
Module that provides a raw editing view of its data as XML. It does not perform

View File

@@ -329,7 +329,7 @@ class MongoModuleStore(ModuleStoreBase):
'''
key = metadata_cache_key(location)
tree = {}
if not force_refresh:
# see if we are first in the request cache (if present)
if self.request_cache is not None and key in self.request_cache.data.get('metadata_inheritance', {}):
@@ -344,7 +344,7 @@ class MongoModuleStore(ModuleStoreBase):
if not tree:
# if not in subsystem, or we are on force refresh, then we have to compute
tree = self.compute_metadata_inheritance_tree(location)
# now write out computed tree to caching subsystem (e.g. memcached), if available
if self.metadata_inheritance_cache_subsystem is not None:
self.metadata_inheritance_cache_subsystem.set(key, tree)
@@ -578,11 +578,8 @@ class MongoModuleStore(ModuleStoreBase):
def fire_updated_modulestore_signal(self, course_id, location):
if self.modulestore_update_signal is not None:
self.modulestore_update_signal.send(None,
modulestore = self,
course_id = course_id,
location = location
)
self.modulestore_update_signal.send(self, modulestore=self, course_id=course_id,
location=location)
def get_course_for_item(self, location, depth=0):
'''
@@ -682,8 +679,7 @@ class MongoModuleStore(ModuleStoreBase):
self._update_single_item(location, {'metadata': metadata})
# recompute (and update) the metadata inheritance tree which is cached
self.refresh_cached_metadata_inheritance_tree(loc)
self.fire_updated_modulestore_signal(get_course_id_no_run(Location(location)), Location(location))
self.fire_updated_modulestore_signal(get_course_id_no_run(Location(location)), Location(location))
def delete_item(self, location):
"""
@@ -707,7 +703,7 @@ class MongoModuleStore(ModuleStoreBase):
safe=self.collection.safe)
# recompute (and update) the metadata inheritance tree which is cached
self.refresh_cached_metadata_inheritance_tree(Location(location))
self.fire_updated_modulestore_signal(get_course_id_no_run(Location(location)), Location(location))
self.fire_updated_modulestore_signal(get_course_id_no_run(Location(location)), Location(location))
def get_parent_locations(self, location, course_id):
'''Find all locations that are the parents of this location in this