Exemple #1
0
        public Stream OpenRead(IndexedBlobReadOptions options = null)
        {
            Stream stream;

            if (_store.Cache.TryGet(FileKey, out stream))
            {
                return(stream);
            }

            if (options == null)
            {
                options = _defaultReadOptions;
            }

            var index = 0;

            if (options.UseSpecificLoadBalancedBlob.HasValue)
            {
                index = Math.Min(options.UseSpecificLoadBalancedBlob.Value, _entity.BlobCount - 1);
            }
            else if (_entity.BlobCount > 1)
            {
                index = _random.Next(_entity.BlobCount);
            }
            var blob = _store.Container.GetBlockBlobReference(string.Format("{0}-{1}", FileKey, index));

            blob.StreamMinimumReadSizeInBytes = options.StreamMinimumReadSizeInBytes;

            stream = blob.OpenRead(options: options.BlobRequestOptions);

            return(_store.Cache.Add(FileKey, stream, _entity.Length));
        }
Exemple #2
0
 public CloudReadonlyIndexedBlob(IIndexedBlobEntity entity, CloudIndexedBlobStore store, IndexedBlobReadOptions defaultReadOptions)
 {
     _entity             = entity;
     _store              = store;
     _defaultReadOptions = defaultReadOptions;
     _random             = new Random();
     Length              = entity.Length;
     _properties         = new Lazy <Dictionary <string, string> >(LoadProperties);
 }
Exemple #3
0
 internal IndexedBlobStoreClient(CloudIndexedBlobStore store)
 {
     _store = store;
     DefaultStorageOptions = new IndexedBlobStorageOptions();
     DefaultReadOptions    = new IndexedBlobReadOptions();
 }