首页 \ 问答 \ 这种基于文件的数据库方法的可扩展性如何?(How scalable is this file-based DB approach?)

这种基于文件的数据库方法的可扩展性如何?(How scalable is this file-based DB approach?)

我有一个简单的PHP脚本,可以计算给定字符串输入的一些内容。 它将结果缓存到数据库,我们偶尔会删除超过特定天数的条目。

我们的程序员将此数据库实现为:

function cachedCalculateThing($input) {
  $cacheFile = 'cache/' . sha1($input) . '.dat';
  if (file_exists($cacheFile) {
    return json_decode(file_get_contents($cacheFile));
  }
  $retval = ...
  file_put_contents(json_encode($retval));
}
function cleanCache() {
  $stale = time() - 7*24*3600;
  foreach (new DirectoryIterator('cache/') as $fileInfo) {
    if ($fileInfo->isFile() && $fileInfo->getCTime() < $stale) {
      unlink($fileInfo->getRealPath());
    }
}

我们使用Ubuntu LAMP和ext3。 在缓存查找变为非常数或违反硬限制的条目数量是多少?


I have a simple PHP script that calculates some things about a given string input. It caches the results to a database and we occasionally delete entries that are older than a certain number of days.

Our programmers implemented this database as:

function cachedCalculateThing($input) {
  $cacheFile = 'cache/' . sha1($input) . '.dat';
  if (file_exists($cacheFile) {
    return json_decode(file_get_contents($cacheFile));
  }
  $retval = ...
  file_put_contents(json_encode($retval));
}
function cleanCache() {
  $stale = time() - 7*24*3600;
  foreach (new DirectoryIterator('cache/') as $fileInfo) {
    if ($fileInfo->isFile() && $fileInfo->getCTime() < $stale) {
      unlink($fileInfo->getRealPath());
    }
}

We use Ubuntu LAMP and ext3. At what number of entries does cache lookup become non-constant or violate a hard limit?


原文:https://stackoverflow.com/questions/38830988
更新时间:2023-07-01 09:07

最满意答案

您是否将MyVcViewModel绑定到您的MyVc ? 如果MyVc可成功用作根/子导航模式,请尝试将其显示为内容(也许您可以将其放在ViewDidLoad()事件中):

var vmRequest = MvxViewModelRequest.GetDefaultRequest(typeof(MyVcViewModel));

var viewController = new MvxViewController();
var myView = viewController.CreateViewControllerFor<MyVcViewModel>(vmRequest) as MyVc;
myView.View.Frame = new CGRect(0, 0, 200, 200);


AddChildViewController(myView);
View.AddSubview(myView.View);

Have you bound the MyVcViewModel to your MyVc? If the MyVc can be used as a root/child navigation pattern successfully, try this to show it as a content (maybe you can put this in ViewDidLoad() event):

var vmRequest = MvxViewModelRequest.GetDefaultRequest(typeof(MyVcViewModel));

var viewController = new MvxViewController();
var myView = viewController.CreateViewControllerFor<MyVcViewModel>(vmRequest) as MyVc;
myView.View.Frame = new CGRect(0, 0, 200, 200);


AddChildViewController(myView);
View.AddSubview(myView.View);

相关问答

更多
  • 我想你真正想要的是从类名创建一个对象 简单的答案是 [[NSClassFromString(className) alloc] init...] 要获得更全面的答案,您应该在Objective-C中查看来自类名的NSString的Create对象 I guess what you really want is to create an object from a classname The simple answer is [[NSClassFromString(className) alloc] ini ...
  • 我发现问题=>显然MvxCachingFragmentCompatActivity由于某种原因不喜欢MvxCachingFragmentCompatActivity 。 第一个样品(工作) 在第一个示例中,我直接在从MvxCachingFragmentCompatActivity扩展的MainViewModel上执行RegisterAppStart<> 。 这是完美的 一些代码示例( 完整代码请参阅链接 ) public class App : MvvmCross.Core.ViewModels.MvxAp ...
  • 你是对的 - 该绑定中使用的默认MvxLanguageConverter实际上只适用于简单的静态文本。 对于更复杂的情况,您需要为每种情况构建自己的转换器 - 但希望其中一些可以重复使用。 作为一个开始示例,请查看Conference示例如何使用TimeAgoConverter.cs显示推文时间 public class TimeAgoValueConverter : MvxBaseValueConverter , IMvxServiceConsumer
  • 您是否将MyVcViewModel绑定到您的MyVc ? 如果MyVc可成功用作根/子导航模式,请尝试将其显示为内容(也许您可以将其放在ViewDidLoad()事件中): var vmRequest = MvxViewModelRequest.GetDefaultRequest(typeof(MyVcViewModel)); var viewController = new MvxViewController(); var myView = viewController.CreateViewContro ...
  • 你的代码有点令人困惑(有点不完整),但我的猜测是你创建了多个ContainerView 一个创建期间: _cv = new ContainerView(); 第二个创建期间 base.Show(request); 如果是这种情况,那么其中只有一个实际显示为RootViewController,而_cv可能会_cv未使用的视图控制器的悬空引用。 要找到解决方案,请尝试查看MvxTouchViewPresenter - 您可以完整地替换此类(如果您不想要任何其功能),或者您可以找到一 ...
  • 该问题与您使用Android LayoutInflater.Inflate方法传递View膨胀的事实有关,而不是使用MvvmCross BindingInflate方法。 using Cirrious.MvvmCross.Binding.Droid.BindingContext; 在您的文件的顶部,以下应该工作: _cardScrollAdapter.AddItem(this.BindingInflate(Resource.Layout.media_panel_view,null)); The issue ...
  • 该跟踪由MvxSidebarViewController中的MvxSidebarViewController代码触发。 protected virtual void SetupSideMenu() { var leftSideMenu = ResolveSideMenu(MvxPanelEnum.Left); var rightSideMenu = ResolveSideMenu(MvxPanelEnum.Right); if (leftSi ...
  • 好的,问题是这个。 我选错了.xib。 苹果 - >空用户界面和Apple - > View之间似乎有区别 课程是:不要使用空用户界面,而是使用视图控制器。 后者创建一个.cs和.xib文件,工作得很好。 Ok, the problem was this. I took the wrong .xib. It seems there is a difference between the Apple -> Empty User Interface and the Apple -> View The lesso ...
  • 试着这样做: var vc = this.CreateViewControllerFor(MvxViewModelRequest.GetDefaultRequest(viewModelType);) as MvxViewController; vc.OnViewCreate(); vc.OnViewCreate(); 应该确保加载了View 。 和行: this.CreateViewControllerFor(MvxViewModelRequest.GetDefaultRequest(vi ...
  • 我相信LegacyBar已经与MvvmCross一起使用 - 所以这肯定是你的选择。 或者,另一个可用选项是为Sherlock中的活动和/或片段添加数据绑定支持。 对于活动,MvvmCross使用几个小的代码层将活动调整为数据绑定: 生活场所 数据绑定上下文 这个代码在MVVMCross for android中描述- 如何在代码中进行绑定? 如果您按照该问题中“附加”部分中的两个步骤操作,那么应该可以创建MvxSherlockActivity 对于片段,这里没有详细的现有答案,但这个过程基本上是相同的两个 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。