Skip to content

Commit

Permalink
Merge branch 'master' of http://www.github.com/websilk/home
Browse files Browse the repository at this point in the history
  • Loading branch information
markentingh committed May 25, 2017
2 parents fa85d45 + 9397d6e commit ccc8cac
Show file tree
Hide file tree
Showing 3 changed files with 199 additions and 129 deletions.
2 changes: 1 addition & 1 deletion App/CSS/tapestry
14 changes: 14 additions & 0 deletions App/Core/Server.cs
Expand Up @@ -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 ccc8cac

Please sign in to comment.