/// <summary> /// Adds a single entity into the cache /// </summary> /// <param name="objectToCache">the entity to cache</param> public void Add <T>(T objectToCache) where T : IData { var entityToCache = (IData)objectToCache; var cacheKey = new BackingDataCacheKey(objectToCache.GetType(), entityToCache.ID); Add <T>(objectToCache, cacheKey); }
/// <summary> /// Removes an entity from the cache by its key /// </summary> /// <param name="key">the key of the entity to remove</param> public void Remove <T>(BackingDataCacheKey key) { Remove <T>(key); }
/// <summary> /// Gets one entity from the cache by its ID, only works for Singleton spawners with data templates(IEntities) /// </summary> /// <typeparam name="T">the type of the entity</typeparam> /// <param name="id">the id</param> /// <returns>the entity requested</returns> public T Get <T>(long id) where T : IData { var key = new BackingDataCacheKey(typeof(T), id); return(Get <T>(key)); }
/// <summary> /// Gets one entity from the cache by its key /// </summary> /// <typeparam name="T">the type of the entity</typeparam> /// <param name="key">the key it was cached with</param> /// <returns>the entity requested</returns> public T Get <T>(BackingDataCacheKey key) where T : IData { return(Get <T>(key.KeyHash())); }
/// <summary> /// Checks if an entity is in the cache /// </summary> /// <param name="key">the key of the entity</param> /// <returns>if it is in the cache of not</returns> public bool Exists(BackingDataCacheKey key) { return(Exists(key)); }