def get_course_content_milestones(course_id, content_id, relationship, user_id=None):
 if (not settings.FEATURES.get('MILESTONES_APP')):
  return []
 if (user_id is None):
  return milestones_api.get_course_content_milestones(course_id, content_id, relationship)
 request_cache_dict = request_cache.get_cache(REQUEST_CACHE_NAME)
 if (user_id not in request_cache_dict):
  request_cache_dict[user_id] = {}
 if (relationship not in request_cache_dict[user_id]):
  request_cache_dict[user_id][relationship] = milestones_api.get_course_content_milestones(course_key=course_id, relationship=relationship, user={'id': user_id})
 return [m for m in request_cache_dict[user_id][relationship] if (m['content_id'] == unicode(content_id))]

def get_course_content_milestones ( course_id , content_id , relationship , user_id = None ) : if ( not settings . FEATURES . get ( 'MILESTONES_APP' ) ) : return [ ] if ( user_id is None ) : return milestones_api . get_course_content_milestones ( course_id , content_id , relationship ) request_cache_dict = request_cache . get_cache ( REQUEST_CACHE_NAME ) if ( user_id not in request_cache_dict ) : request_cache_dict [ user_id ] = { } if ( relationship not in request_cache_dict [ user_id ] ) : request_cache_dict [ user_id ] [ relationship ] = milestones_api . get_course_content_milestones ( course_key = course_id , relationship = relationship , user = { 'id' : user_id } ) return [ m for m in request_cache_dict [ user_id ] [ relationship ] if ( m [ 'content_id' ] == unicode ( content_id ) ) ]
client api operation adapter/wrapper uses the request cache to store all of a users milestones .