Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 仅为读取已保存的结果激活Dask缓存_Python_Caching_Dask - Fatal编程技术网

Python 仅为读取已保存的结果激活Dask缓存

Python 仅为读取已保存的结果激活Dask缓存,python,caching,dask,Python,Caching,Dask,我想知道是否可以停用Dask缓存以保存新值,而不是读取已缓存的值 例如,我运行以下代码,只计算一次a,然后检索保存的值: import dask from dask.cache import Cache cache = Cache(2e9) cache.register() @dask.delayed def add(i): print("Executed") return i+1 a = add(1) print(a.compute()) print(

我想知道是否可以停用Dask缓存以保存新值,而不是读取已缓存的值

例如,我运行以下代码,只计算一次
a
,然后检索保存的值:

import dask
from dask.cache import Cache
cache = Cache(2e9)
cache.register()

@dask.delayed
def add(i):
    print("Executed")
    return i+1

a = add(1)
print(a.compute())

print(a.compute())
执行

二,

二,

如果然后调用
cache.unregister
我会避免保存
b
的结果,但当我再次调用
a.compute
时,会执行函数
add

cache.unregister()
b = add(2)
print(b.compute())
执行

三,

执行

二,

{'add-f0a48927-5f2d-4995-b53f-34630d5c944e':2}

因此,我想知道是否可以将缓存配置为从
a.compute()
读取结果,但不从
b.compute()
保存新结果。我需要一个全局选项,如
cache.unregister()
,因为我正在处理一个大型库,无法逐个元素进行操作

谢谢

print(a.compute())

print(cache.cache.data)