def resolve(self, state): '''Ensure filter code and blob argument are available in the blob cache, load the blob argument, and initialize the cache digest.''' if self.code_path is not None: return # Get path to filter code code_path, code_signature = self._resolve_code(state) # Get contents of blob argument blob, blob_signature = self._resolve_blob(state) # Initialize digest summary = ([code_signature, self.name] + self.arguments + [blob_signature]) cache_digest = murmur(' '.join(summary)) # Commit self.code_path = code_path self.signature = code_signature self.blob = blob self.cache_digest = cache_digest
def get_cache_key(self, obj): '''Return the result cache lookup key for previous filter executions on this object.''' return 'result:' + murmur(self._get_cache_digest() + ' ' + str(obj))
# # The OpenDiamond Platform for Interactive Search # # Copyright (c) 2011 Carnegie Mellon University # All rights reserved. # # This software is distributed under the terms of the Eclipse Public # License, Version 1.0 which can be found in the file named LICENSE. # ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES # RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT # '''Filter configuration and execution; result and attribute caching. There are two caches, both accessible via key lookups in the same Redis database. Result cache: 'result:' + murmur( ' '.join( murmur( ' '.join( SHA256(filter code), filter name, ' '.join(filter arguments), SHA256(filter blob argument), ), ), object ID ) ) => JSON({
def __setitem__(self, key, value): self._attrs[key] = value self._signatures[key] = murmur(value)
def get_signature(rtype, *args, **kargs): return murmur(rtype + ''.join(map(str, args)) + ''.join(map(str, kargs.keys())) + ''.join(map(str, kargs.values())))
def get_signature(rtype, *args): return murmur(rtype + '' + ''.join(args))