All Projects → point-platform → cassette

point-platform / cassette

Licence: Apache-2.0 license
A simple content-addressable storage system for .NET 4.5 and .NET Core

Programming Languages

C#
18002 projects
powershell
5483 projects

Projects that are alternatives of or similar to cassette

ent
No description or website provided.
Stars: ✭ 33 (-2.94%)
Mutual labels:  cas, content-addressable-storage
cas-overlay-template
Apereo CAS WAR Overlay template
Stars: ✭ 1,057 (+3008.82%)
Mutual labels:  cas
eu-login-bundle
EU Login bundle, a standard Symfony bundle to authenticate users against EU Login.
Stars: ✭ 25 (-26.47%)
Mutual labels:  cas
django-allauth-cas
CAS support for django-allauth.
Stars: ✭ 15 (-55.88%)
Mutual labels:  cas
TairString
A redis module, similar to redis string, but you can set expire and version for the value. It also provides many very useful commands, such as cas/cad, etc.
Stars: ✭ 99 (+191.18%)
Mutual labels:  cas
racket-cas
Simple computer algebra system
Stars: ✭ 58 (+70.59%)
Mutual labels:  cas
jax-rs-pac4j
Security library for JAX-RS and Jersey
Stars: ✭ 48 (+41.18%)
Mutual labels:  cas
shib-cas-authn3
Integrates an external CAS Server and Shibboleth IdPv3.
Stars: ✭ 21 (-38.24%)
Mutual labels:  cas
grails-spring-security-cas
No description or website provided.
Stars: ✭ 16 (-52.94%)
Mutual labels:  cas
orb
A DID method implementation that extends the Sidetree protocol into a Fediverse of interconnected nodes and witnessed using certificate transparency. Spec: https://trustbloc.github.io/did-method-orb/
Stars: ✭ 25 (-26.47%)
Mutual labels:  content-addressable-storage
CAS
修改好的cas单点登录项目
Stars: ✭ 72 (+111.76%)
Mutual labels:  cas
django-uniauth
A Django app for managing CAS and custom user authentication.
Stars: ✭ 39 (+14.71%)
Mutual labels:  cas
rascas
Computer Algebra System for Racket
Stars: ✭ 20 (-41.18%)
Mutual labels:  cas
doit
spring cloud , CAS , JHipster hybrid sample app
Stars: ✭ 14 (-58.82%)
Mutual labels:  cas
lemonldap-ng
LemonLDAP::NG main code
Stars: ✭ 49 (+44.12%)
Mutual labels:  cas
psrcas
PSR CAS, a PHP standard library for CAS authentication.
Stars: ✭ 21 (-38.24%)
Mutual labels:  cas
cas-bootadmin-overlay
CAS Spring Boot Admin Server Overlay Template
Stars: ✭ 20 (-41.18%)
Mutual labels:  cas
CRISPRCasTyper
CCTyper: Automatic detection and subtyping of CRISPR-Cas operons
Stars: ✭ 43 (+26.47%)
Mutual labels:  cas
smeagol-galore
A git-based wiki featuring markdown, a WYSIWYG Editor, PlantUML, and much more
Stars: ✭ 21 (-38.24%)
Mutual labels:  cas
kernel xiaomi sm8250
CLO Rebased kernel for Xiaomi SM8250 series devices updated to CAF tag LA.UM.9.12.r1-14700-SMxx50 with AOSP android-4.19-stable merged.
Stars: ✭ 111 (+226.47%)
Mutual labels:  cas

Cassette

Build status Cassette NuGet version

Cassette is a simple and efficient content-addressable storage system for .NET 4.5 and .NET Core (netstandard1.3).

// Create a store, backed by the specified file system location
var cassette = new ContentAddressableStore(@"c:\cassette-data\");

// Store some content, obtaining its hash (content address)
Hash hash = await cassette.WriteAsync(writeStream);

// Later, use the hash to look up the content
Stream stream;
if (cassette.TryRead(hash, out stream, ReadOptions.Asynchronous | ReadOptions.SequentialScan))
{
    using (stream)
    {
        // Read the stored content via the returned read-only stream
        var buffer = new byte[4096];
        var bytesRead = await stream.ReadAsync(buffer, 0, buffer.Length);
        // ...
    }
}

Content-addressable storage (CAS) is a fast and efficient mechanism for storing and retrieving fixed data on disk.

Information is uniquely and unambiguously identified by the SHA-1 hash of its contents.

A significant advantage of CAS is its efficient use of storage media for data backups where a majority of files are identical, and so separate storage would be redundant.

For more information, read Wikipedia's CAS article.


Types

  • IContentAddressableStore exposes functionality of a cassette store
  • ContentAddressableStore is the concrete implementation
  • Hash holds the identity of a piece of content

Writing content

using (var stream = File.OpenRead(@"c:\content.jpg"))
{
    var hash = await store.WriteAsync(dataStream);
    Console.WriteLine("Stored with address: {0}", hash);
}

The hash is computed efficiently by observing content during buffered writes to a temporary location of the file system. Then:

  • if the content does not already exist, the file is atomically moved into location and marked as read-only
  • if the content does already exist, the temporary file is deleted and the store is unchanged

This means writes are idempotent. Repeated writes of the same content do not increase the size of the store on disk, though do incur disk IO.

Reading

Read operations atomically test for the availability of a file and open it for reading if present.

Multiple clients may read a file concurrently. Content may not be deleted via IContentAddressableStore.Delete while a read stream is open.

When TryRead returns true, client code must dispose the returned Stream.

Hash hash = ...;
Stream stream;
if (store.TryRead(hash, out stream))
{
    using (stream)
    {
        // Use the stream
    }
}

The performance of reads can be improved by specifying ReadOptions as described in sections async IO and access patterns and performance.

  • None indicates no special options. This is the default.
  • SequentialScan indicates data will be read sequentially.
  • RandomAccess indicates seek operations will be performed during reading.
  • Asynchronous indicates Stream.ReadAsync will be used.
store.TryRead(hash, out stream, ReadOptions.SequentialScan | ReadOptions.ReadAsync)

Asynchronous IO

Write operations happen using asynchronous IO and return awaitable tasks to prevent blocking calling code. Use of a CancellationToken allows immediate cancellation of the write operation.

Read operations occur using Streams which support asynchronous IO themselves via ReadAsync and CopyToAsync. When using these asynchronous methods you can improve performance by passing ReadOptions.Asynchronous to IContentAddressableStore.TryRead.

On Windows these asynchronous operations use IO Completion ports (MSDN, Dr. Dobbs). Other platforms may have implementations using suitable alternatives.

Access patterns and performance

When writing content to disk, cassette notifies the file system that data will be written sequentially and that no random-access seeking will occur. This allows the caching system to prepare pages of data efficiently which can significantly reduce latency.

When reading content from disk, users can get the same caching benefits by specifying ReadOptions.SequentialScan or ReadOptions.RandomAccess. This is optional however.

Deleting content

Content may be deleted from the store by calling Delete with the relevant hash.

Measuring content length

If the length of stored content is to be retrieved, it is most efficient to use TryGetContentLength which provides the length in bytes.

Enumerating content

The complete set of hashes is returned via GetHashes. This method computes the enumerable lazily by walking the file system so is thread-safe with respect to reads and writes. However it cannot be relied upon to behave deterministically if enumerating while content is being written or deleted. Whether new or deleted content is included in an enumeration whose processing spans the write/delete may or may not contain the affected content.

Encoding

Cassette supports optionally storing content using an encoding. The primary use case for this is to store pre-compressed data whereby the cost of compressing content is taken upfront once at write time, rather than for each read.

Content may be stored in multiple encodings. For example, an HTTP server may support both no encoding, or GZIP content/transfer encoding. Such an HTTP handler could request either encoding from the store depending upon request headers.

// Instantiate a content encoding
var gzipEncoding = new GZipContentEncoding();

// Write some (unencoded) content to the store, and request an encoded copy be stored
var hash = await store.WriteAsync(stream, encodings: new[] { gzipEncoding });

// Read the encoded content out directly
Stream gzipStream;
if (store.TryRead(hash, out gzipStream, encodingName: gzipEncoding.Name))
{
    using (gzipStream)
    {
        // Use the GZipped data directly
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].