需要说明Docpad的持久性 [英] Need explanation for Docpad persistence

查看:105
本文介绍了需要说明Docpad的持久性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Docpad中如何持久存储数据的架构感到非常困惑.从博客和论坛中,我了解到内存(和/或出目录)用于生成内容.但是Docpad的卖点之一是完全基于文件".从它的声音来看,将其托管在Heroku或任何临时文件系统上似乎并不合逻辑.谁能提供一些解释/澄清?

解决方案

DocPad被称为下一代Web体系结构.此思维导图说明了为什么我们如此称呼它:

DocPad体系结构远景http://d.pr/i/jmmZ+

工作流程如下:

  1. 进口商可以从任何来源将数据引入本地文件系统,tumblr或mongo数据库.
  2. 这些被注入到DocPad内存数据库中
  3. 在生成时,DocPad将呈现需要呈现的内容,并将静态内容输出到out目录中
  4. 动态文档(根据每个请求重新呈现的文档)和动态功能(服务器扩展)现在可以使用内存数据库,并执行高级的高级功能,例如文件上传,联系表格,搜索页面等,

从这个意义上讲,DocPad是具有静态站点生成功能以及动态站点生成功能的下一代Web体系结构. DocPad与传统的Web体系结构的区别在于,传统的Web体系结构考虑了内容并确定了分离的存在,其中DocPad认为它们是相同的,只是通过扩展进行了分离.传统的Web体系结构默认情况下也是动态的,通过缓存完成静态站点的生成,而不是默认情况下是静态的.

由于这会在内存数据库中加载所有内容,因此在生成和生成后,我们正遭受越来越多的性能困扰. 在这里讨论.但是,没有什么事情是没有足够的时间和资源来解决的.无论如何,由于具有静态特性(更快的请求)和异步特性(更快的生成),DocPad仍将比传统的Web体系结构更快.

关于如何处理文件上传:

  • 如果您使用DocPad做一个静态网站,那么您将在其他地方有一个后端API服务器,您也将进行上传并将数据作为单页应用程序样式加载到DocPad中.

  • 如果您使用DocPad创建动态网站,则可以将DocPad托管在Heroku等服务器上,并扩展该服务器以处理将文件上传到目的地(例如Amazon S3,Dropbox或MongoDB等)的过程.然后,您可以选择通过templateData作为链接公开文件,或将文件作为文件注入到DocPad内存数据库中.您选择的是您是只想引用上传文件还是将其视为DocPad Universe中的头等公民(它获得了自己的URL和页面).

对于动态网站,我会说我真的喜欢静态网站+单页应用程序方法.您将获得诸如响应式设计,脱机支持,非常快速的UX之类的好处,而如果不这样做,无论采用哪种Web体系结构,都很难通过动态站点方法来完成它.

I am pretty confused with the architecture behind how data is persisted in Docpad. From blogs and forums, I got to know in-memory (and/or out directory) is used for generated contents. But one of the selling points of Docpad is "completely file based". From the sound of it, hosting it on Heroku or any ephemeral file system doesn't seem logical. Can anyone give some explanation/clarification?

解决方案

DocPad is pitched as a next generation web architecture. This mindmap showcases why we call it that perfectly:

DocPad Architecture Vision http://d.pr/i/jmmZ+

The workflow being like so:

  1. Importers bring data in, from any source, be it the local file system, or tumblr, or mongo database.
  2. These get injected into the DocPad in-memory database
  3. At generation time, DocPad will then render what needs to be rendered, and output static content into the out directory
  4. Dynamic documents (documents that re-render on each request) and dynamic abilities (server extensions) are now able to make use of the in memory database and perform advanced cool stuff like file uploads, contact forms, search pages, whatever

In that sense, DocPad is a next generation web architecture that has static site generation abilities, as well as dynamic site generation abilities. What separates DocPad from traditional web architectures, is that traditional web architectures consider the content and templating separate beings, where DocPad considers them the same and just separated by their extension. Traditional web architectures also are dynamic by defaults, with static site generation accomplished via caching, rather than the other way round of being static by default.

Because of this load everything in the in-memory database situation, we are suffering some from growing pains with performance during generation and post-generation. Discussion here. However there is nothing there that can't be fixed with enough time and resources. Regardless of this, DocPad will still be faster than your traditional web architecture due to the static nature (faster requests) as well as the asynchronous nature (faster generations).

In terms of how you would handle file uploads:

  • If you are doing a static website with DocPad, you would have a backend API server somewhere else that you would do the upload too and load the data into DocPad as a single page application style.

  • If you are doing a dynamic website with DocPad, you would host DocPad on a server like Heroku, and extend the server to handle the file upload to a destination like Amazon S3, Dropbox, or into MongoDB or the like. You can then choose to expose the file via templateData as a link, or inject the file into the DocPad in-memory database as a file. Which one you chose is whether or not you just want to reference the upload or treat it as a first class citizen in the DocPad universe (it gets it's own URL and page).

For dynamic sites, I would say I really go with the static site + single page application approach. You get benefits like responsive design, offline support, really fast UX which without doing it that way, you struggle a bit accomplishing it with the dynamic site approach regardless of which web architecture you build it on.

这篇关于需要说明Docpad的持久性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆