在磁盘上缓存PHP对象之间有区别吗?如果缓存,则只为所有站点访问者创建一次对象,如果没有,则为每个访问者创建一次.这有性能差异还是我会浪费时间做这个?
基本上,当涉及到它时,主要问题是:
内存中的多个对象,PER用户(每个用户都有自己的一组实例化对象)
VS
所有用户在文件中缓存的单个对象(所有用户使用相同的对象,例如,相同的错误处理程序类,相同的模板处理程序类和相同的数据库句柄类)
我一直在研究Timer类(http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx),但关于计时器的事情是,它正在进行中.有一种方法可以一次性阻止它吗?还是5点之后?
现在我正在做以下事情:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
namespace TimerTest
{
class Program
{
private static System.Timers.Timer aTimer;
static void Main(string[] args)
{
DoTimer(1000, delegate
{
Console.WriteLine("testing...");
aTimer.Stop();
aTimer.Close();
});
Console.ReadLine();
}
public static void DoTimer(double interval, ElapsedEventHandler elapseEvent)
{
aTimer = new Timer(interval);
aTimer.Elapsed += new ElapsedEventHandler(elapseEvent);
aTimer.Start();
}
}
}
Run Code Online (Sandbox Code Playgroud) 我想显示所有客户及其地址以及订单数量和总金额。我的查询如下所示:
select *, sum(o.tota), count(o.total)
from customer c
natural join orders o
group by c.custId;
Run Code Online (Sandbox Code Playgroud)
效果很好。
但如果我向查询添加一个新表:
select *, sum(o.tota), count(o.total)
from customer c
natural join orders o
natural join cust_addresses a
group by c.custId;
Run Code Online (Sandbox Code Playgroud)
那么它就不再起作用了。聚合函数返回错误的值,因为每个客户可能有多个地址,这是正确的,我也想显示他们的所有地址。我该如何解决聚合函数问题?
我可以考虑做类似的事情:
select *, (select total from orders o where o.custid=c.custid), ..
from customer c
natural join orders o
natural join cust_addresses a
group by c.custId;
Run Code Online (Sandbox Code Playgroud)
但这非常慢。
编辑 我现在尝试了以下操作,但它告诉我字段 c.custid 未知:
select *
from
customer c,
left join (select sum(o.tota), count(o.total) from orders o where …Run Code Online (Sandbox Code Playgroud) 我有多个按钮,每个按钮都有一个32x32像素的PNG图像.奇怪的是,两个按钮显示不同的大小(是的,我三重检查图标真的是32x32!).秒按钮看起来像48x48像素大小.最有趣的是,如果省略该Stretch="None"属性,图标将按比例放大以填充整个屏幕.
我无法解释自己为什么会这样!
<ToolBar Name="toolBar1" DockPanel.Dock="Top">
<Button Name="importButton" ToolTip="Import" Click="importButton_Click">
<Image Source="Icons/Import.png" Stretch="None" />
</Button>
<Button Name="toggleDetails" ToolTip="Details for Item" Click="toggleDetails_Click">
<Image Source="Icons/maximize.png" Stretch="None" />
</Button>
</ToolBar>
<StackPanel Name="stackPanel1" DockPanel.Dock="Top" Orientation="Horizontal" Margin="0,5,0,5">
<Label Name="label2" Content="Find"></Label>
<TextBox Name="tags" Width="400" KeyDown="tags_KeyDown" />
<Button ToolTip="Find" Name="findItemsButton" Click="findItemsButton_Click">
<Image Source="Icons/xmag.png" Stretch="None" />
</Button>
<CheckBox Content="Show Closed" Name="showClosedItemsCheckBox" VerticalAlignment="Center" Margin="10,0,0,0" Click="showClosedItemsCheckBox_Click" />
</StackPanel>
<TabControl Name="tabControl" TabStripPlacement="Top">
</TabControl>
</DockPanel>
Run Code Online (Sandbox Code Playgroud)
我必须遵循以下代码:
List<Obj> coll = new List<Obj>();
if (cond1) coll.Add(new Obj { /*...*/ });
if (cond2) coll.Add(new Obj { /*...*/ });
if (cond3) coll.Add(new Obj { /*...*/ });
Run Code Online (Sandbox Code Playgroud)
有没有办法使用LINQ或集合初始化器?
编辑:
我想在这里使用集合初始化器的原因是因为我有一个对象树,我用initialiers和LINQ完全初始化.这个地方是唯一一个不遵循这一原则的地方.
var myobj = new MyBigObj
{
Prop1 = from .. select ..,
Prop2 = from .. select ..,
...
Prop3 = new MySmallerObj
{
PropSmall1 = from .. select ..,
PropSmall2 = from .. select ..,
...
}
};
Run Code Online (Sandbox Code Playgroud)
而现在这根本不适合我的计划:
List<Obj> coll = new List<Obj>();
if (cond1) coll.Add(new Obj { …Run Code Online (Sandbox Code Playgroud) 我尝试在我的三星s2上安装cyanogenmod.我设法成功地在启动设备时启动的设备上安装了氰基恢复.
之后,我尝试安装cyanogenmod,这让我错误:
adb push "cm-12.1-20160129-NIGHTLY-i9100.zip" /storage/sdcard0
error: device unauthorized.
This adb server's $ADB_VENDOR_KEYS is not set
Try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.
Run Code Online (Sandbox Code Playgroud)
我已经尝试杀死并重新启动adb服务器,并尝试usb使用Zadig 安装不同的驱动程序.
我已经读过必须在设备上启用USB调试,但问题是我无法启动android以设置该选项,我只得到一个带有黄色感叹号的启动屏幕,并且在cyanogenmod恢复菜单出现之后.我不确定这个选项是否是问题的根源.
现在这个设备是砖砌还是有办法安装cyanogenmod或至少恢复原来的android?
我得到编译错误,因为编译器认为Path.Combine引用了我的字段,但我希望它引用类System.IO.Path.除了总是必须编写类似System.IO.Path.Combine()的FQN之外,还有一种处理这个问题的好方法吗?
using System.IO;
class Foo
{
public string Path;
void Bar(){ Path.Combine("",""); } // compile error here
}
Run Code Online (Sandbox Code Playgroud) 有没有人知道ZIP的缩写代表什么是PKZIP和GZIP这样的程序?有一种名为Lempel-Ziv-Welch-Algorithm(LZW)的压缩算法可能是名叫Ziv的人与其他人一起发明的ZIP?
我找不到任何关于它的东西,也许它不是缩写,而是它只是意味着"压缩文件",但我认为最初有更多关于它...
我正在尝试将对象添加到组合框中并使用SelectedValue属性来选择组合框中的项目但是它不起作用:SelectedValue在赋值后仍然为null.
class ComboBoxItem
{
string name;
object value;
public string Name { get { return name; } }
public object Value { get { return value; } }
public ComboBoxItem(string name, object value)
{
this.name = name;
this.value = value;
}
public override bool Equals(object obj)
{
ComboBoxItem item = obj as ComboBoxItem;
return item!=null && Value.Equals(item.Value);
}
}
operatorComboBox.Items.Add(new ComboBoxItem("Gleich", SearchOperator.OpEquals));
operatorComboBox.Items.Add(new ComboBoxItem("Ungleich", SearchOperator.OpNotEquals));
operatorComboBox.ValueMember="Value";
//SelectedValue is still null after this statement
operatorComboBox.SelectedValue = SearchOperator.OpNotEquals;
Run Code Online (Sandbox Code Playgroud) 鉴于我有一个IEnumerable(e)和一个T(t)值.最简单的做法是什么:
IEnumerable<T> newCollection = t+e
Run Code Online (Sandbox Code Playgroud)
目前我正在做的事情:
ItemArray = Enumerable.Repeat<object>(t, 1).Concat(e);
Run Code Online (Sandbox Code Playgroud)
这是相当难以理解的,因为我在这里没有真正重复.我也尝试过:
IEnumerable<T> newCollection = new List<object> { t}.Concat(e);
Run Code Online (Sandbox Code Playgroud)
但是这个创建了一个不必要的List对象,它也不是最优的.
有没有人有更好的主意?
.net ×4
c# ×4
collections ×2
linq ×2
abbreviation ×1
acronym ×1
adb ×1
algorithm ×1
android ×1
button ×1
caching ×1
collision ×1
combobox ×1
cyanogenmod ×1
data-binding ×1
events ×1
generics ×1
history ×1
image ×1
namespaces ×1
object ×1
oop ×1
performance ×1
php ×1
properties ×1
select ×1
sql ×1
sqlite ×1
stretch ×1
syntax-error ×1
timer ×1
winforms ×1
wpf ×1
zip ×1