public string GetCollectionName(Type type)
        {
            CacheBase cache = null;

            caches.TryGetValue(type, out cache);
            return(cache?.collectionName);
        }
        public ETTask <T> FindOne <T>(long id) where T : ComponentWithId
        {
            var       type  = typeof(T);
            CacheBase cache = null;

            caches.TryGetValue(type, out cache);
            ETTaskCompletionSource <T> tcs  = new ETTaskCompletionSource <T>();
            CacheFindOneTask <T>       task = ComponentFactory.CreateWithId <CacheFindOneTask <T>, CacheBase, ETTaskCompletionSource <T> >(id, cache, tcs);

            this.tasks[(int)((ulong)task.Id % taskCount)].Add(task);
            return(tcs.Task);
        }
        public ETTask <T> Upsert <T>(T entity) where T : ComponentWithId
        {
            var       type  = typeof(T);
            CacheBase cache = null;

            caches.TryGetValue(type, out cache);
            ETTaskCompletionSource <T> tcs  = new ETTaskCompletionSource <T>();
            CacheUpsertTask <T>        task = ComponentFactory.Create <CacheUpsertTask <T>, CacheBase, T, ETTaskCompletionSource <T> >(cache, entity, tcs);

            this.tasks[(int)((ulong)task.Id % taskCount)].Add(task);
            return(tcs.Task);
        }
        public ETTask <T> FindOneByUniqueIndex <T>(string indexName, T entity) where T : ComponentWithId
        {
            var       type  = typeof(T);
            CacheBase cache = null;

            caches.TryGetValue(type, out cache);
            ETTaskCompletionSource <T>        tcs  = new ETTaskCompletionSource <T>();
            CacheFindOneByUniqueIndexTask <T> task = ComponentFactory.Create <CacheFindOneByUniqueIndexTask <T>, CacheBase, Tuple <string, T>, ETTaskCompletionSource <T> >
                                                         (cache, new Tuple <string, T>(indexName, entity), tcs);

            this.tasks[(int)((ulong)task.Id % taskCount)].Add(task);
            return(tcs.Task);
        }
 public override void Awake(CacheFindAllByIndexTask <ComponentWithId> self, CacheBase proxy, Tuple <string, ComponentWithId> para, ETTaskCompletionSource <List <ComponentWithId> > tcs)
 {
     self.proxy     = proxy;
     self.Tcs       = tcs;
     self.parameter = para;
 }
 public override void Awake(CacheUpdateTask <ComponentWithId> self, CacheBase proxy, ComponentWithId entity, ETTaskCompletionSource <ComponentWithId> tcs)
 {
     self.proxy  = proxy;
     self.Tcs    = tcs;
     self.entity = entity;
 }
Example #7
0
 public override void Awake(CacheDeleteTask <ComponentWithId> self, CacheBase proxy, ETTaskCompletionSource <bool> tcs)
 {
     self.proxy = proxy;
     self.Tcs   = tcs;
 }