示例#1
0
        def fill():
            alldicts = {}
            from invenio.legacy.bibrank.tag_based_indexer import fromDB
            redis = get_redis()
            serialized_weights = redis.get('citations_weights')
            if serialized_weights:
                weights = deserialize_via_marshal(serialized_weights)
            else:
                weights = fromDB('citation')

            alldicts['citations_weights'] = weights
            # for cited:M->N queries, it is interesting to cache also
            # some preprocessed citationdict:
            alldicts['citations_keys'] = intbitset(weights.keys())

            # Citation counts
            alldicts['citations_counts'] = [t for t in iteritems(weights)]
            alldicts['citations_counts'].sort(key=itemgetter(1), reverse=True)

            # Self-cites
            serialized_weights = redis.get('selfcites_weights')
            if serialized_weights:
                selfcites = deserialize_via_marshal(serialized_weights)
            else:
                selfcites = fromDB('selfcites')
            selfcites_weights = {}
            for recid, counts in alldicts['citations_counts']:
                selfcites_weights[recid] = counts - selfcites.get(recid, 0)
            alldicts['selfcites_weights'] = selfcites_weights
            alldicts['selfcites_counts'] = [(recid, selfcites_weights.get(recid, cites)) for recid, cites in alldicts['citations_counts']]
            alldicts['selfcites_counts'].sort(key=itemgetter(1), reverse=True)

            return alldicts
示例#2
0
        def fill():
            alldicts = {}
            from invenio.legacy.bibrank.tag_based_indexer import fromDB
            redis = get_redis()
            serialized_weights = redis.get('citations_weights')
            if serialized_weights:
                weights = deserialize_via_marshal(serialized_weights)
            else:
                weights = fromDB('citation')

            alldicts['citations_weights'] = weights
            # for cited:M->N queries, it is interesting to cache also
            # some preprocessed citationdict:
            alldicts['citations_keys'] = intbitset(weights.keys())

            # Citation counts
            alldicts['citations_counts'] = [t for t in iteritems(weights)]
            alldicts['citations_counts'].sort(key=itemgetter(1), reverse=True)

            # Self-cites
            serialized_weights = redis.get('selfcites_weights')
            if serialized_weights:
                selfcites = deserialize_via_marshal(serialized_weights)
            else:
                selfcites = fromDB('selfcites')
            selfcites_weights = {}
            for recid, counts in alldicts['citations_counts']:
                selfcites_weights[recid] = counts - selfcites.get(recid, 0)
            alldicts['selfcites_weights'] = selfcites_weights
            alldicts['selfcites_counts'] = [
                (recid, selfcites_weights.get(recid, cites))
                for recid, cites in alldicts['citations_counts']
            ]
            alldicts['selfcites_counts'].sort(key=itemgetter(1), reverse=True)

            return alldicts
示例#3
0
 def setUp(self):
     from invenio.utils.redis import get_redis
     self.db = get_redis()
示例#4
0
def store_weights_cache(weights):
    """Store into key/value store"""
    redis = get_redis()
    redis.set("citations_weights", serialize_via_marshal(weights))
示例#5
0
def store_weights_cache(weights):
    """Store into key/value store"""
    redis = get_redis()
    redis.set('selfcites_weights', serialize_via_marshal(weights))
示例#6
0
def store_weights_cache(weights):
    """Store into key/value store"""
    redis = get_redis()
    redis.set('citations_weights', serialize_via_marshal(weights))
示例#7
0
 def save_in_storage(self, sid, session_object, timeout, uid):  # pylint: disable=W0613
     return get_redis().setex(self.generate_key(sid),
                              session_object,
                              timeout)
示例#8
0
 def setUp(self):
     from invenio.utils.redis import get_redis
     self.db = get_redis()
示例#9
0
 def delete_from_storage(self, sid):
     return get_redis().delete(self.generate_key(sid))
示例#10
0
 def load_from_storage(self, sid):
     return get_redis().get(self.generate_key(sid))
示例#11
0
 def save_in_storage(self, sid, session_object, timeout, uid):  # pylint: disable=W0613
     return get_redis().setex(self.generate_key(sid),
                              session_object,
                              timeout)
示例#12
0
 def delete_from_storage(self, sid):
     return get_redis().delete(self.generate_key(sid))
示例#13
0
 def load_from_storage(self, sid):
     return get_redis().get(self.generate_key(sid))