def get(self, key=None):
if key:<EOL><INDENT>key = ub_to_str(key)<EOL>if settings.ENABLE_CACHING:<EOL><INDENT>return self.get_from_cache(key) or self.set_to_cache(self._get_from_riak(key))<EOL><DEDENT>else:<EOL><INDENT>return self._get_from_riak(key)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self._exec_query()<EOL>if not self._solr_cache['<STR_LIT>']:<EOL><INDENT>raise ObjectDoesNotExist("<STR_LIT>" % (self.index_name, self.compiled_query))<EOL><DEDENT>if self.count() > <NUM_LIT:1>:<EOL><INDENT>raise MultipleObjectsReturned(<EOL>"<STR_LIT>" % (self.count(),<EOL>self._model_class.__name__))<EOL><DEDENT>return self._get_from_riak(self._solr_cache['<STR_LIT>'][<NUM_LIT:0>]['<STR_LIT>'])<EOL><DEDENT>
If key is not None, tries to get obj from cache first. If not
found, tries to get from riak and sets to cache.

If key is None, then execute solr query and checks result. Returns
obj data and key tuple or raises exception ObjectDoesNotExist or
MultipleObjectsReturned.

Args:
    key(str): obj key
Return:
    (tuple): obj data dict, obj key