dogpile缓存的文件系统后端

dogpile-filesystem的Python项目详细描述


dogpile缓存的文件系统后端

PyPIBuild StatusCoverage Status

dogpile缓存的基于文件系统的后端。

后端的泛型变量paylogic.filesystem将接受任何可选择的值,并将其存储在文件系统中。

原始变量paylogic.raw_filesystem将只与类似文件的值一起工作,它将避免pickling阶段当您生成一个大文件并且不想将该文件的内容保存在内存中时,这非常有用。

两种变体都使用fcntl.lockf操作,因此它只与类unix系统兼容。 lockf系统调用允许使用同一文件分配任意数量的锁,从而避免删除锁文件时出现的问题

安装

使用pip安装:

$ pip install dogpile_filesystem

用法

通用变型

配置区域以使用paylogic.filesystem

fromdogpile.cacheimportmake_regionimportdatetimeregion=make_region().configure('paylogic.filesystem',arguments={"base_dir":"/path/to/cachedir",# Make sure this directory is only for this region# Optional parameters"cache_size":1024**3,# Defaults to 1 Gb"expiration_time":datetime.timedelta(seconds=30),# Defaults to no expiration"distributed_lock":True,# Defaults to true})@region.cache_on_arguments()defmy_function(args):return42

原始变量

配置区域以使用dogpile_文件系统:

fromdogpile.cacheimportmake_regionimportdatetimeimporttempfileregion=make_region().configure('paylogic.raw_filesystem',arguments={"base_dir":"/path/to/cachedir",# Make sure this directory is only for this region# Optional parameters"cache_size":1024**3,# Defaults to 1 Gb"file_movable":True,# Whether the backend can freely move the file.# When True, the backend will move the file to the cache# directory directly using os.rename(file.name).# When False (default), the content of the file will be copied to # the cache directory."expiration_time":datetime.timedelta(seconds=30),# Defaults to no expiration"distributed_lock":True,# Defaults to true})@region.cache_on_arguments()defbig_file_operation(args):# When using `file_movable=True`, we must make sure that NamedTemporaryFile does not delete the file on close,# otherwise it will complain that it cannot find the file.f=tempfile.NamedTemporaryFile(delete=False)# fill the filef.flush()f.seek(0)returnf

开发

以开发模式安装开发需求和项目:

$ pip install -r requirements_dev.txt -e .

运行测试:

$ pytest tests

可选地对所有支持的配置运行测试:

$ tox

更改日志

该项目的所有显著变化都将记录在本文件中。

这个项目遵循Semantic Versioning

未发布

0.2.0条

  • 删除了在file_movable=True但文件似乎不可移动时返回到复制文件的逻辑。不要试图变得聪明。

0.1.1

  • 让pypi知道我们使用降价

0.1.0条

  • 初始版本

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Vaadin 8网格布局删除行之间的多余空间   java Spring启动应用程序,用于读取jar的属性文件,该jar是在运行测试时作为依赖项添加的   在嵌套函数中调用java Gpload时速度较慢   java JSP:刷新文件的代码   java如何区分泛型类和类型参数?   java如何在JTextPane中获取插入符号周围的字符串?   java无法在glassfish4服务器中部署websocket应用程序   java Spring,在同一个URL上发布不同的模型   java我们可以将printwriter与Apache poi工作表一起使用吗   不带数组的java Int序列   java LinkedList返回方法   java如何正确创建字符串对数组?   java如何在谷歌地图上选择正确的缩放   java设置标签的位置   多线程在Erlang比单线程Java快之前需要多少CPU   未使用Fresco将java图像加载到gridView   复制粘贴时发生java Classnotfoundexception。从以前的项目到新项目的ser文件   java如何在安卓和NDK上使用C函数   java JPA与传统原生SQL共存   java NoNodeAvailableException[没有配置的节点可用:[{{transport}1}{ifvrlxsusudgvyfzl_Rabkg}{10.10.10.109}{10.10.10.109:9300}]