Skip to content

FoundatioBuilding Blocks for Distributed Apps

Pluggable foundation blocks for building loosely coupled distributed applications

Foundatio

Quick Example

Caching

csharp
using Foundatio.Caching;

ICacheClient cache = new InMemoryCacheClient();
await cache.SetAsync("test", 1);
var value = await cache.GetAsync<int>("test");

Queues

csharp
using Foundatio.Queues;

IQueue<SimpleWorkItem> queue = new InMemoryQueue<SimpleWorkItem>();

await queue.EnqueueAsync(new SimpleWorkItem { Data = "Hello" });
var workItem = await queue.DequeueAsync();

Locks

csharp
using Foundatio.Lock;

ILockProvider locker = new CacheLockProvider(
    new InMemoryCacheClient(),
    new InMemoryMessageBus()
);
var testLock = await locker.AcquireAsync("test");
// ... do work
await testLock.ReleaseAsync();

Messaging

csharp
using Foundatio.Messaging;

IMessageBus messageBus = new InMemoryMessageBus();
await messageBus.SubscribeAsync<SimpleMessage>(msg => {
  // Got message
});

await messageBus.PublishAsync(new SimpleMessage { Data = "Hello" });

File Storage

csharp
using Foundatio.Storage;

IFileStorage storage = new InMemoryFileStorage();
await storage.SaveFileAsync("test.txt", "test");
string content = await storage.GetFileContentsAsync("test.txt");

Why Foundatio?

When building several large cloud applications we found a lack of great solutions for many key pieces to building scalable distributed applications while keeping the development experience simple. Here's why we built and use Foundatio:

  • Abstract Interfaces: Build against abstract interfaces so you can easily change implementations
  • DI Friendly: All blocks are dependency injection friendly
  • Local Development: In-memory implementations mean no external dependencies during development
  • Swappable: Easily swap between in-memory (development) and production implementations (Redis, Azure, AWS)
  • Battle Tested: Used in production at Exceptionless and other large-scale applications

Implementations

ProviderCachingQueuesMessagingLocksStorage
In-Memory
Redis
Azure Storage
Azure ServiceBus
AWS
Kafka
RabbitMQ
Minio
Aliyun
SshNet
  • Foundatio.Mediator - Blazingly fast, convention-based C# mediator powered by source generators and interceptors. Near-direct call performance with zero runtime reflection.

Released under the Apache 2.0 License.