|
1 | | - |
| 1 | + |
2 | 2 |
|
3 | | -[](https://badge.fury.io/nu/ServiceBricks) |
4 | | - |
| 3 | +[](https://badge.fury.io/nu/ServiceBricks.Cache.Microservice) |
| 4 | + |
5 | 5 | [](https://opensource.org/licenses/MIT) |
6 | 6 |
|
7 | | -# ServiceBricks: The Microservices Foundation |
| 7 | +# ServiceBricks Cache Microservice |
8 | 8 |
|
9 | 9 | ## Overview |
10 | 10 |
|
11 | | -[ServiceBricks](https://ServiceBricks.com) is a powerful microservices platform designed to streamline the development, deployment, and maintenance of distributed systems using artificial intelligence. |
12 | | -Leveraging Domain-Driven Design (DDD), Event-Driven Architecture (EDA), and a host of advanced features, ServiceBricks empowers teams to create scalable, customizable services tailored to specific business domains. |
| 11 | +This repository contains the cache microservice built using the ServiceBricks foundation. |
| 12 | +The cache microservice exposes a key/value pair object that can be used for simple data storage. |
| 13 | +It includes a semaphore, exposing a locking mechanism that can be used by multiple servers when needing to access a shared resource. |
| 14 | +A background expiration task can be enabled, with an initial delay and interval, to delete expired cache items once their expiration date occurs. |
| 15 | +The expiration process duals as an orphaned lock cleanup, should a lock not be released within the timeout period. |
13 | 16 |
|
14 | | -## Why ServiceBricks? |
| 17 | +## Data Transfer Objects |
15 | 18 |
|
16 | | -* **Artificial Intelligence:** Use our online generator to create production-grade microservices in seconds using only a single human sentence as input. |
17 | | -* **Advanced Architecture:** Provides the core architectural patterns, implementation, standardization, and governance for your microservices. |
18 | | -* **REST APIs:** Expose standardized, secure REST APIs to manage your data. |
19 | | -* **Storage Agnostic:** Interchangeably supports relational, document, cloud or embedded database engines |
20 | | -* **Seamless Integration:** Switch storage providers without impacting microservice operations and avoid vendor lock-in. |
| 19 | +### CacheDataDto - Admin Policy |
| 20 | +Key and Value pair storage object along with an expiration date to denote when it can be deleted. |
21 | 21 |
|
| 22 | +```csharp |
22 | 23 |
|
23 | | -## Major Features |
| 24 | + public partial class CacheDataDto : DataTransferObject |
| 25 | + { |
| 26 | + public DateTimeOffset CreateDate { get; set; } |
| 27 | + public DateTimeOffset UpdateDate { get; set; } |
| 28 | + public string CacheKey { get; set; } |
| 29 | + public string CacheValue { get; set; } |
| 30 | + public DateTimeOffset? ExpirationDate { get; set; } |
24 | 31 |
|
25 | | -* **Artificial Intelligence Integration:** Use large language models to build, query and manipulate your microservice data using simple human input. |
26 | | -* **Generics:** Extensive use of generics, allowing the compiler to generate most of the required source code. |
27 | | -* **REST API Services:** Templated, repository-based services for quickly exposing standard CRUD+QPV (Query, Patch, Validate) methods or custom methods. |
28 | | -* **[ServiceQuery Integration](https://github.com/holomodular/ServiceQuery):** Supports standardized, polyglot, dynamic data querying for all database engines. |
29 | | -* **[Business Rule Engine](https://github.com/holomodular/ServiceBricks-Documentation/blob/main/V1/BusinessRuleEngine.md):** Polymorphic techniques to build reusable business logic. |
30 | | -* **[Domain-Driven Design (DDD)](https://github.com/holomodular/ServiceBricks-Documentation/blob/main/V1/FlowOfData.md) & [Event-Driven Architecture (EDA)](https://github.com/holomodular/ServiceBricks-Documentation/blob/main/V1/EventDrivenArchitecture.md):** Customize business logic for any supported object and method. |
31 | | -* **[Background Processing](https://github.com/holomodular/ServiceBricks-Documentation/blob/main/V1/BackgroundTasks.md):** Supports asynchronous processes, tasks, and rules. |
32 | | -* **[Relational, Document, Cloud and Embedded Database Support](https://github.com/holomodular/ServiceBricks-Documentation/blob/main/V1/SupportedDatabaseEngines.md):** Works standard with Azure Data Tables, Cosmos DB, InMemory, MongoDB, Postgres, SQLite, SQL Server and more. |
33 | | -* **[Service Bus Engine](https://github.com/holomodular/ServiceBricks-Documentation/blob/main/V1/BroadcastsAndServiceBus.md):** Supports broadcasts of system data with InMemory and Azure Service Bus. |
34 | | -* **[Classic or Modern REST API Design](https://github.com/holomodular/ServiceBricks-Documentation/blob/main/V1/ClassicVsModernRestApi.md):** Choose between Classic or Modern modes, with various response formats. |
35 | | -* **[NuGet Packages](https://github.com/holomodular/ServiceBricks-Documentation/blob/main/V1/NuGet.md):** Quickly build new services and applications. |
36 | | -* **Testing Framework:** Comprehensive Xunit test framework for robust unit and integration testing with thousands of tests available. |
37 | | -* **Open Source:** All referenced assemblies are open source and licensed under MIT or an equivalent license. |
| 32 | + } |
38 | 33 |
|
| 34 | +``` |
39 | 35 |
|
40 | | -## Getting Started with Examples |
41 | 36 |
|
42 | | -Explore our [ServiceBricks-Examples](https://github.com/holomodular/ServiceBricks-Examples) repository for practical examples on hosting and deploying your ServiceBricks foundation. From single, monolithic web applications to distributed, multi-deployment, containerized web applications, these examples provide the building blocks to create and scale your own foundations quickly. |
| 37 | +## Background Tasks and Timers |
43 | 38 |
|
44 | | -## Documentation |
| 39 | +### CacheExpirationTimer class |
| 40 | +This background timer can be enabled, with an initial delay and interval, to execute the CacheExpirationTask. |
45 | 41 |
|
46 | | -Check out our [ServiceBricks-Documentation](https://github.com/holomodular/ServiceBricks-Documentation) repository for comprehensive documentation on the platform, including guides on using all components and developing your own microservices. |
| 42 | +[View Source](https://github.com/holomodular/ServiceBricks-Cache/blob/main/src/V1/ServiceBricks.Cache/Background/CacheExpirationTimer.cs) |
47 | 43 |
|
48 | | -## Official Pre-Built Microservices |
| 44 | +### CacheExpirationTask class |
| 45 | +This background task queries for all CacheData records with an expiration date is less than the current date/time, then deletes expired records. |
49 | 46 |
|
50 | | -Get started quickly with our pre-built microservices: |
| 47 | +[View Source](https://github.com/holomodular/ServiceBricks-Cache/blob/main/src/V1/ServiceBricks.Cache/Background/CacheExpirationTask.cs) |
51 | 48 |
|
52 | | -* [ServiceBricks-Cache](https://github.com/holomodular/ServiceBricks-Cache): Generic data storage microservice with a built in expiration process and a distributed semaphore for cache-level locking for multi-instance deployments. |
53 | | -* [ServiceBricks-Logging](https://github.com/holomodular/ServiceBricks-Logging): Service-scoped or centralized logging and a web request auditing microservice. |
54 | | -* [ServiceBricks-Notification](https://github.com/holomodular/ServiceBricks-Notification): Notification and delivery for emails and SMS messages. |
55 | | -* [ServiceBricks-Security](https://github.com/holomodular/ServiceBricks-Security): Authentication, authorization, and application security with JWT bearer token support for multi-instance deployments. |
56 | | -* [ServiceBricks-Work](https://github.com/holomodular/ServiceBricks-Work): Work queue microservice for reliable, event-driven background processing. |
| 49 | +## Events |
| 50 | +None |
57 | 51 |
|
58 | | -## Trademarks |
| 52 | +## Processes |
| 53 | +None |
59 | 54 |
|
60 | | -“ServiceBricks”, "ServiceQuery" and “HoloModular” are trademarks of HoloModular LLC. The MIT License covers code only; it does not grant rights to use our trademarks, logos, or brand assets (including in modified or redistributed versions) without permission. |
| 55 | +## Service Bus |
| 56 | +None |
61 | 57 |
|
62 | | -## About |
| 58 | +## Additional Services |
| 59 | + |
| 60 | +### SemaphoreService |
| 61 | +This provides a locking mechanism for shared resources in the infrastructure. Using the CacheData object, multiple concurrent services try creating the same key/record in the backing storage, the one that wins pulls records, then releases/deletes the lock. Processes will delay and retry creating the lock until it obtains it or times out. See the SemaphoreOptions for the full list of values used. |
| 62 | + |
| 63 | +[View Source](https://github.com/holomodular/ServiceBricks-Cache/blob/main/src/V1/ServiceBricks.Cache.Model/Service/SemaphoreService.cs) |
| 64 | + |
| 65 | +### SingleServerProcessService |
| 66 | +This interface stores a key in cache used for syncing across load-balanced applications so that only one server would process records at a time (see SingleWorkService). It provides a heartbeat, so that other instances will pickup and start processing, should the main running server be shut down. |
| 67 | + |
| 68 | +[View Source](https://github.com/holomodular/ServiceBricks-Cache/blob/main/src/V1/ServiceBricks.Cache.Model/Service/SingleServerProcessService.cs) |
| 69 | + |
| 70 | +### SingleWorkService class |
| 71 | +This abstract class implements the WorkService and the ISingleServerProcessService to provide a single ordered work queue across multi-application instances. |
| 72 | + |
| 73 | +[View Source](https://github.com/holomodular/ServiceBricks-Cache/blob/main/src/V1/ServiceBricks.Cache.Model/Service/SingleWorkService.cs) |
| 74 | + |
| 75 | +### LockedWorkService class |
| 76 | +This abstract class provides a way to lock the underlying data store and use it as a queue, so that multiple, simultaneous running workers do not return the same records. While the APIConcurrrency rule provides some protection, this class will provide the full solution. |
| 77 | + |
| 78 | +[View Source](https://github.com/holomodular/ServiceBricks-Cache/blob/main/src/V1/ServiceBricks.Cache.Model/Service/LockedWorkService.cs) |
| 79 | + |
| 80 | +## Application Settings |
| 81 | + |
| 82 | +```csharp |
| 83 | +{ |
| 84 | + "ServiceBricks":{ |
| 85 | + "Cache":{ |
| 86 | + "Expiration": { |
| 87 | + "TimerEnabled": false, |
| 88 | + "TimerIntervalMilliseconds": 7000, |
| 89 | + "TimerDueMilliseconds": 1000 |
| 90 | + }, |
| 91 | + "Semaphore": { |
| 92 | + "DelayMilliseconds": 3000, |
| 93 | + "CancellationMilliseconds": 20000, |
| 94 | + "OrphanTimeoutMilliseconds": 10000 |
| 95 | + } |
| 96 | + } |
| 97 | + } |
| 98 | +} |
| 99 | +``` |
| 100 | + |
| 101 | +# About ServiceBricks |
| 102 | + |
| 103 | +ServiceBricks is the cornerstone for building a microservices foundation. |
| 104 | +Visit http://ServiceBricks.com to learn more. |
63 | 105 |
|
64 | | -ServiceBricks is owned and maintained by HoloModular LLC and authored by Danny Logsdon (Founder). Visit our websites at https://HoloModular.com, https://ServiceBricks.com or https://www.linkedin.com/in/danlogsdon to learn more. |
|
0 commit comments