Store result in disk cache with key matching model state.
768173
def set_disk_cache(self, results, key=None):
        """"""
        if not getattr(self, 'disk_cache_location', False):
            self.init_disk_cache()
        disk_cache = shelve.open(self.disk_cache_location)
        key = self.model.hash if key is None else key
        disk_cache[key] = results
        disk_cache.close()
1123518
def cached_stan_file(model_name='anon_model', file=None, model_code=None,
                  cache_dir=None, fit_cachefile=None, cache_only=None, force=False,
                  include_modelfile=False, prefix_only=False,
                  **kwargs
                  ):
    ''' 
    '''
    model_prefix, model_cachefile = cached_model_file(model_name=model_name, file=file, model_code=model_code,
                                                      cache_dir=cache_dir, fit_cachefile=fit_cachefile, include_prefix=True)
    if not fit_cachefile:
        fit_cachefile = '.'.join([model_prefix, 'stanfit', _make_digest(dict(**kwargs)), 'pkl'])
    if include_modelfile:
        return model_cachefile, fit_cachefile
    if prefix_only:
        fit_cachefile = re.sub(string=fit_cachefile, pattern='.pkl$', repl='')
    return fit_cachefile
801665
def store_result(self, message, result: Result, ttl: int) -> None:
        
        message_key = self.build_message_key(message)
        return self._store(message_key, result, ttl)
131024
def _store_work_results(self, results, collection, md5):
        
        self.data_store.store_work_results(results, collection, md5)
13725
def _get_cache_plus_key(self):
        """"""
        key = getattr(self, '_cache_key', self.key_from_query())
        return self._cache.cache, key
1274379
def clean_cache(cached, **kwargs):
    "  "

    if isinstance(cached, basestring):
        cached = _str_to_model(cached)

    cache_key = generate_cache_key(cached, **kwargs)
    cache.delete(cache_key)
939457
def update_cache(self, data):
        """"""
        UTILS.update(self._cache, data)
        self._save_cache()
663367
function(result, callback) {
            self.cache.put(result, function(err, doc) {
                if (err) return callback(err);
                callback(null, result, doc._id);
            });
        }
802494
def assoc(m, key, val):
    """"""
    cpy = deepcopy(m)
    cpy[key] = val
    return cpy
439636
def _store_result(self, task_id, result, status,
                      traceback=None, request=None):
        """"""
        self.TaskModel._default_manager.store_result(
            task_id, result, status,
            traceback=traceback, children=self.current_task_children(request),
        )
        return result
1165900
def reflect(source, model, cache=None):
    ''''''
    if source is None:
        return None
    if cache and source in cache:
        return cache[source]
    db = object_session(source)
    ident = identity_key(instance=source)[1]
    assert ident is not None
    return db.query(model).get(ident)
174164
def put(self, key, data):
        
        try:
            return self._dstore.put(key, data)
        finally:
            self.cache.delete(key)
1204940
private Resource mightCache(String key, Resource fileResource) {
        if ( ! isDevMode() ) {
            lookupCache.put(key,fileResource);
        }
        return fileResource;
    }
928384
def store(self, key, data):
        """"""
        if not os.path.exists(self._hash_dir):
            os.makedirs(self._hash_dir)

        if isinstance(data, pd.DataFrame):
            columns = data.columns.tolist()
            np.save(os.path.join(self._hash_dir, key), data.values)
            json.dump(columns, open(os.path.join(self._hash_dir, '%s.json' % key), 'w'))
        else:
            np.save(os.path.join(self._hash_dir, key), data)
589636
def _cache(self, key, val):
        
        cache_size = (1 if util.dimensionless_contents(self.streams, self.kdims)
                      else self.cache_size)
        if len(self) >= cache_size:
            first_key = next(k for k in self.data)
            self.data.pop(first_key)
        self[key] = val
1163069
def cache_generator(self, key, generator):
        """"""
        results = []
        for result in generator:
            results.append(result)
            yield result

        self.inferred[key] = tuple(results)
712308
def get(self, *args, **kwargs):
        """"""
        assert not args
        assert list(kwargs.keys()) == ['pk']
        pk = kwargs['pk']
        model_name = self.model.__name__
        object_spec = (model_name, pk, None)
        instances = self.cache.get_instances((object_spec,))
        try:
            model_data = instances[(model_name, pk)][0]
        except KeyError:
            raise self.model.DoesNotExist(
                "No match for %r with args %r, kwargs %r" %
                (self.model, args, kwargs))
        else:
            return CachedModel(self.model, model_data)