public static T Get <T>(string name) where T : class, new() { string cacheKey = "object-" + name; T t = ZCache.Get <T>(cacheKey); if (t == null) { ObjectStore os = ObjectStore.FetchByColumn(ObjectStore.Columns.Name, name); if (os.IsLoaded) { t = ConvertToObject <T>(os.Data); } else { t = new T(); } if (t == null) { throw new Exception("Type " + typeof(T) + " could not be found or created"); } ZCache.MaxCache(cacheKey, t); } return(t); }
public static void Delete(string name) { ObjectStore os = ObjectStore.FetchByColumn(ObjectStore.Columns.Name, name); ObjectStore.Destroy(os.Id); ZCache.RemoveCache("object-" + name); }
private static void Save(Widget widget, bool resetCache) { ObjectStore os = ObjectStore.FetchByColumn(ObjectStore.Columns.Name, widget.Id.ToString()); os.Data = ObjectManager.ConvertToString(widget); os.Save(); if (resetCache) { Reset(); } }
private static void UpdateFeed(Feed feed, bool resetCache) { ObjectStore os = ObjectStore.FetchByColumn(ObjectStore.Columns.UniqueId, feed.Id); os.Data = ObjectManager.ConvertToString(feed); os.Version++; os.Save(); if (resetCache) { ZCache.RemoveCache("Feed-Objects"); } }
public static void Save(object objectToSave, string name) { ObjectStore os = ObjectStore.FetchByColumn(ObjectStore.Columns.Name, name); os.Data = ConvertToString(objectToSave); if (!os.IsLoaded) { os.ContentType = "xml/serialization"; os.Name = name; os.Type = objectToSave.GetType().FullName; os.Version++; } os.Save(); ZCache.RemoveCache("object-" + name); ZCache.InsertCache("object-" + name, objectToSave, 120); }