Permalink
Browse files

added server cache lambda function

  • Loading branch information...
markentingh committed May 25, 2017
1 parent 3cba906 commit 9397d6e5324d95aa6d27e1d201cda9f9686d725a
Showing with 15 additions and 1 deletion.
  1. +1 −1 App/CSS/tapestry
  2. +14 −0 App/Core/Server.cs
Submodule tapestry updated 3 files
+31 −57 less/theme.less
+0 −12 less/util.less
+131 −160 tapestry.less
@@ -131,6 +131,20 @@ public void SaveToCache(string key, string value)
Cache.Add(key, value);
}
}
public T GetFromCache<T>(string key, Func<T> value, bool serialize = true)
{
if(Cache[key] == null)
{
var obj = value();
SaveToCache(key, serialize ? S.Util.Serializer.WriteObjectAsString(obj) : obj);
return obj;
}
else
{
return serialize ? (T)S.Util.Serializer.ReadObject((string)Cache[key], typeof(T)) : (T)Cache[key];
}
}
#endregion
}
}

0 comments on commit 9397d6e

Please sign in to comment.