BinaryRage.Storage.WritetoStorage C# (CSharp) Метод

WritetoStorage() публичный статический Метод

public static WritetoStorage ( string key, byte value, string filelocation ) : void
key string
value byte
filelocation string
Результат void
        public static void WritetoStorage(string key, byte[] value, string filelocation)
        {
            //create folders
            string dirstructure = createDirectoriesBasedOnKeyAndFilelocation(key, filelocation);

            //Write the file to it's location
            try
            {
                File.WriteAllBytes(CombinePathAndKey(dirstructure, key), value);

                lock (Cache.LockObject)
                {
                    //remove object from cache
                    Cache.CacheDic.Remove(filelocation + key);
                }
            }
            catch (Exception)
            {

            }

            Interlocked.Decrement(ref Cache.counter);
        }

Usage Example

Пример #1
0
        static public void Insert <T>(string key, T value, string filelocation)
        {
            Interlocked.Increment(ref Cache.counter);
            SimpleObject simpleObject = new SimpleObject {
                Key = key, Value = value, FileLocation = filelocation
            };

            sendQueue.Add(simpleObject);
            var data = sendQueue.Take(); //this blocks if there are no items in the queue.

            //Add to cache
            lock (Cache.LockObject)
            {
                Cache.CacheDic[filelocation + key] = simpleObject;
            }

            ThreadPool.QueueUserWorkItem(state =>
            {
                lock (Cache.LockObject)
                {
                    Storage.WritetoStorage(data.Key, Compress.CompressGZip(ConvertHelper.ObjectToByteArray(value)),
                                           data.FileLocation);
                }
            });
        }
All Usage Examples Of BinaryRage.Storage::WritetoStorage