Post.latestRevision is cached now

main
Inga 🏳‍🌈 13 years ago
parent 23e08a88f3
commit 3e6cc1ad8f
  1. 2
      Builder/IISMainHandler/build.txt
  2. 49
      FLocal.Common/dataobjects/Post.cs

@ -28,7 +28,10 @@ namespace FLocal.Common.dataobjects {
public static readonly TableSpec instance = new TableSpec(); public static readonly TableSpec instance = new TableSpec();
public string name { get { return TABLE; } } public string name { get { return TABLE; } }
public string idName { get { return FIELD_ID; } } public string idName { get { return FIELD_ID; } }
public void refreshSqlObject(int id) { Refresh(id); } public void refreshSqlObject(int id) {
Refresh(id);
LoadById(id).latestRevision_Reset();
}
} }
protected override ISqlObjectTableSpec table { get { return TableSpec.instance; } } protected override ISqlObjectTableSpec table { get { return TableSpec.instance; } }
@ -70,31 +73,39 @@ namespace FLocal.Common.dataobjects {
return this._revision; return this._revision;
} }
} }
private readonly object latestRevision_locker = new object();
public Revision latestRevision { public Revision latestRevision {
get { get {
return Revision.LoadById( return Cache<Revision>.instance.get(
int.Parse( this.latestRevision_locker,
Config.instance.mainConnection.LoadIdsByConditions( () => Revision.LoadById(
Revision.TableSpec.instance, int.Parse(
new ComplexCondition( Config.instance.mainConnection.LoadIdsByConditions(
ConditionsJoinType.AND, Revision.TableSpec.instance,
new ComparisonCondition( new ComplexCondition(
Revision.TableSpec.instance.getColumnSpec(Revision.TableSpec.FIELD_POSTID), ConditionsJoinType.AND,
ComparisonType.EQUAL, new ComparisonCondition(
this.id.ToString() Revision.TableSpec.instance.getColumnSpec(Revision.TableSpec.FIELD_POSTID),
ComparisonType.EQUAL,
this.id.ToString()
),
new ComparisonCondition(
Revision.TableSpec.instance.getColumnSpec(Revision.TableSpec.FIELD_NUMBER),
ComparisonType.EQUAL,
this.revision.Value.ToString()
)
), ),
new ComparisonCondition( Diapasone.unlimited
Revision.TableSpec.instance.getColumnSpec(Revision.TableSpec.FIELD_NUMBER), ).Single()
ComparisonType.EQUAL, )
this.revision.Value.ToString()
)
),
Diapasone.unlimited
).Single()
) )
); );
} }
} }
internal void latestRevision_Reset() {
Cache<Revision>.instance.delete(this.latestRevision_locker);
}
private int _layerId; private int _layerId;
public int layerId { public int layerId {

Loading…
Cancel
Save