@@ -55,6 +55,7 @@ DynamoDB is Amazon's fully managed NoSQL database service that provides fast and
5555### Via Application.cfc
5656
5757Configure the cache at the application level in your ` Application.cfc ` :
58+
5859``` javascript
5960this .name = " myApp" ;
6061
@@ -79,6 +80,7 @@ this.caches = {
7980### Via .CFConfig.json
8081
8182For server-wide configuration, add the cache definition to your ` .CFConfig.json ` file located at ` {lucee-server}/context/.CFConfig.json ` :
83+
8284``` json
8385{
8486 "caches" : {
@@ -144,6 +146,7 @@ For server-wide configuration, add the cache definition to your `.CFConfig.json`
144146## Configuration Examples
145147
146148### Production Configuration (AWS)
149+
147150``` javascript
148151this .caches = {
149152 " dynamodb" : {
@@ -164,6 +167,7 @@ this.caches = {
164167```
165168
166169### Development Configuration (DynamoDB Local)
170+
167171``` javascript
168172this .caches = {
169173 " dynamodb" : {
@@ -187,6 +191,7 @@ this.caches = {
187191### EC2/ECS Configuration (IAM Roles)
188192
189193When running on EC2 or ECS with IAM roles, you don't need to provide credentials:
194+
190195``` javascript
191196this .caches = {
192197 " dynamodb" : {
@@ -210,6 +215,7 @@ Once configured, you can use all standard Lucee cache functions with your Dynamo
210215### Basic Operations
211216
212217#### Store Data in Cache
218+
213219``` javascript
214220// Simple string value
215221cachePut (id= " user_session_123" , value= " active" , cacheName= " dynamodb" );
@@ -235,6 +241,7 @@ cachePut(
235241```
236242
237243#### Retrieve Data from Cache
244+
238245``` javascript
239246// Get value (throws error if not found)
240247var sessionData = cacheGet (id= " user_session_123" , cacheName= " dynamodb" );
@@ -253,6 +260,7 @@ if(cacheIdExists(id="user_session_123", cacheName="dynamodb")) {
253260```
254261
255262#### Delete from Cache
263+
256264``` javascript
257265// Delete single item
258266cacheDelete (id= " user_session_123" , cacheName= " dynamodb" );
@@ -267,6 +275,7 @@ cacheClear(cacheName="dynamodb");
267275### Advanced Operations
268276
269277#### Working with Multiple Items
278+
270279``` javascript
271280// Get all cache IDs
272281var allIds = cacheGetAllIds (cacheName= " dynamodb" );
@@ -283,6 +292,7 @@ var totalItems = cacheCount(cacheName="dynamodb");
283292```
284293
285294#### Cache Metadata
295+
286296``` javascript
287297// Get metadata for a cache entry
288298var metadata = cacheGetMetadata (id= " user_profile_456" , cacheName= " dynamodb" );
@@ -298,6 +308,7 @@ var metadata = cacheGetMetadata(id="user_profile_456", cacheName="dynamodb");
298308### Data Type Support
299309
300310The DynamoDB cache extension supports all native Lucee data types:
311+
301312``` javascript
302313// Strings
303314cachePut (id= " key1" , value= " Simple string" , cacheName= " dynamodb" );
@@ -332,6 +343,7 @@ cachePut(id="key7", value=qryData, cacheName="dynamodb");
332343The DynamoDB extension fully supports cache expiration using DynamoDB's native TTL feature.
333344
334345### Setting Expiration
346+
335347``` javascript
336348// Expire after 1 hour
337349cachePut (
@@ -369,6 +381,7 @@ cachePut(
369381## Use Cases
370382
371383### Session Storage
384+
372385``` javascript
373386// Store user session
374387function createUserSession (userID , sessionData ) {
@@ -399,6 +412,7 @@ function getUserSession(sessionID) {
399412```
400413
401414### API Rate Limiting
415+
402416``` javascript
403417function checkRateLimit (apiKey , maxRequests = 100 , timeWindow = 3600 ) {
404418 var cacheKey = " ratelimit_" & hash (apiKey);
@@ -432,6 +446,7 @@ function checkRateLimit(apiKey, maxRequests=100, timeWindow=3600) {
432446```
433447
434448### Query Result Caching
449+
435450``` javascript
436451function getCachedQueryResults (sql , cacheMinutes = 15 ) {
437452 var cacheKey = " query_" & hash (sql);
@@ -463,6 +478,7 @@ function getCachedQueryResults(sql, cacheMinutes=15) {
463478```
464479
465480### Distributed Lock Implementation
481+
466482``` javascript
467483function acquireLock (resourceName , timeout = 30 ) {
468484 var lockKey = " lock_" & resourceName;
@@ -508,19 +524,23 @@ For local development and testing, you can use DynamoDB Local instead of AWS Dyn
508524### Installing DynamoDB Local
509525
510526#### Using Docker
527+
511528``` bash
512529docker run -p 8000:8000 amazon/dynamodb-local:latest
513530```
514531
515532#### Using Java (Manual Installation)
516533
5175341 . Download DynamoDB Local from [ AWS Developer Guide] ( https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html )
535+
5185362 . Extract and run:
537+
519538``` bash
520539java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb
521540```
522541
523542### Local Configuration
543+
524544``` javascript
525545this .caches = {
526546 " dynamodb" : {
@@ -541,6 +561,7 @@ this.caches = {
541561```
542562
543563### Environment-Based Configuration
564+
544565``` javascript
545566// Detect environment
546567var isDevelopment = (server .coldfusion .productname contains " Lucee" ) &&
@@ -581,6 +602,7 @@ this.caches = {
581602### Best Practices
582603
5836041 . ** Use Appropriate Key Names** : Create meaningful, namespaced keys to avoid collisions
605+
584606``` javascript
585607 // Good
586608 cachePut (id= " user:123:profile" , value= data, cacheName= " dynamodb" );
@@ -590,6 +612,7 @@ this.caches = {
590612```
591613
5926142 . ** Implement Cache Warming** : Pre-populate frequently accessed data
615+
593616``` javascript
594617 function warmCache () {
595618 var criticalData = queryExecute (" SELECT * FROM frequently_accessed" );
@@ -604,6 +627,7 @@ this.caches = {
604627```
605628
6066293 . ** Use Batch Operations** : Leverage ` cacheGetAll() ` for multiple items
630+
607631``` javascript
608632 // Efficient: single query
609633 var userData = cacheGetAll (filter= " user_*" , cacheName= " dynamodb" );
@@ -615,6 +639,7 @@ this.caches = {
615639```
616640
6176414 . ** Set Appropriate TTL** : Balance between freshness and performance
642+
618643``` javascript
619644 // Frequently changing data: short TTL
620645 cachePut (id= " stock_price" , value= price, timeSpan= createTimeSpan (0 ,0 ,1 ,0 ), cacheName= " dynamodb" );
@@ -626,6 +651,7 @@ this.caches = {
626651### Monitoring and Optimization
627652
6286531 . ** Enable Logging** : Monitor cache operations
654+
629655``` javascript
630656 custom: {
631657 " log" : " dynamodb" ,
0 commit comments