@@ -42,7 +42,7 @@ let future2 = try userLoader.load(key: 2, on: eventLoopGroup)
4242let  future3 =  try  userLoader.load (key : 1 , on : eventLoopGroup)
4343``` 
4444
45- The example above will only fetch two users, because the user with key ` 1 `  is present twice in the list.  
45+ The example above will only fetch two users, because the user with key ` 1 `  is present twice in the list.
4646
4747### Load multiple keys  
4848There is also a method to load multiple keys at once
@@ -52,14 +52,14 @@ try userLoader.loadMany(keys: [1, 2, 3], on: eventLoopGroup)
5252
5353### Execution  
5454By default, a DataLoader will wait for a short time from the moment ` load `  is called to collect keys prior
55- to running the ` batchLoadFunction `  and completing the ` load `  futures. This is to let keys accumulate and  
56- batch into a smaller number of total requests. This amount of time is configurable using the ` executionPeriod `   
55+ to running the ` batchLoadFunction `  and completing the ` load `  futures. This is to let keys accumulate and
56+ batch into a smaller number of total requests. This amount of time is configurable using the ` executionPeriod ` 
5757option:
5858
5959``` swift 
6060let  myLoader =   DataLoader< String , String > (
6161    options : DataLoaderOptions (executionPeriod : .milliseconds (50 )),
62-     batchLoadFunction : { keys in   
62+     batchLoadFunction : { keys in 
6363        self .someBatchLoader (keys : keys).map  { DataLoaderFutureValue.success ($0 ) }
6464    }
6565)
@@ -68,10 +68,10 @@ let myLoader =  DataLoader<String, String>(
6868Longer execution periods reduce the number of total data requests, but also reduce the responsiveness of the
6969` load `  futures.
7070
71- If desired, you can manually execute the ` batchLoadFunction `  and complete the futures at any time, using the  
71+ If desired, you can manually execute the ` batchLoadFunction `  and complete the futures at any time, using the
7272` .execute() `  method.
7373
74- Scheduled execution can be disabled by setting ` executionPeriod `  to ` nil ` , but be careful - you * must*  call ` .execute() `   
74+ Scheduled execution can be disabled by setting ` executionPeriod `  to ` nil ` , but be careful - you * must*  call ` .execute() ` 
7575manually in this case. Otherwise, the futures will never complete!
7676
7777### Disable batching  
@@ -80,10 +80,10 @@ In this case, the `batchLoadFunction` will be invoked immediately when a key is
8080
8181
8282## Caching 💰  
83- DataLoader provides a memoization cache. After ` .load() `  is called with a key, the resulting value is cached  
83+ DataLoader provides a memoization cache. After ` .load() `  is called with a key, the resulting value is cached
8484for the lifetime of the DataLoader object. This eliminates redundant loads.
8585
86- In addition to relieving pressure on your data storage, caching results also creates fewer objects which may  
86+ In addition to relieving pressure on your data storage, caching results also creates fewer objects which may
8787relieve memory pressure on your application:
8888
8989``` swift 
@@ -134,15 +134,15 @@ userLoader.load(key: 4, on: eventLoopGroup)
134134
135135### Caching Errors  
136136
137- If a batch load fails (that is, a batch function throws or returns a DataLoaderFutureValue.failure(Error)),  
137+ If a batch load fails (that is, a batch function throws or returns a DataLoaderFutureValue.failure(Error)),
138138then the requested values will not be cached. However if a batch
139139function returns an ` Error `  instance for an individual value, that ` Error `  will
140140be cached to avoid frequently loading the same ` Error ` .
141141
142142In some circumstances you may wish to clear the cache for these individual Errors:
143143
144144``` swift 
145- userLoader.load (key : 1 , on : eventLoopGroup).whenFailure  { error in   
145+ userLoader.load (key : 1 , on : eventLoopGroup).whenFailure  { error in 
146146    if  (/*  determine if should clear error */ 
147147        userLoader.clear (key : 1 );
148148    }
@@ -167,7 +167,7 @@ For example:
167167``` swift 
168168let  myLoader =   DataLoader< String , String > (
169169    options : DataLoaderOptions (cachingEnabled : false ),
170-     batchLoadFunction : { keys in   
170+     batchLoadFunction : { keys in 
171171        self .someBatchLoader (keys : keys).map  { DataLoaderFutureValue.success ($0 ) }
172172    }
173173)
@@ -195,7 +195,7 @@ let myLoader = DataLoader<String, String>(batchLoadFunction: { keys in
195195## Using with GraphQL 🎀  
196196
197197DataLoader pairs nicely well with [ GraphQL] ( https://github.com/GraphQLSwift/GraphQL )  and
198- [ Graphiti] ( https://github.com/GraphQLSwift/Graphiti ) . GraphQL fields are designed to be  
198+ [ Graphiti] ( https://github.com/GraphQLSwift/Graphiti ) . GraphQL fields are designed to be
199199stand-alone functions. Without a caching or batching mechanism,
200200it's easy for a naive GraphQL server to issue new database requests each time a
201201field is resolved.
@@ -222,7 +222,7 @@ Consider the following GraphQL request:
222222Naively, if ` me ` , ` bestFriend `  and ` friends `  each need to request the backend,
223223there could be at most 12 database requests!
224224
225- By using DataLoader, we could batch our requests to a ` User `  type, and  
225+ By using DataLoader, we could batch our requests to a ` User `  type, and
226226only require at most 4 database requests, and possibly fewer if there are cache hits.
227227Here's a full example using Graphiti:
228228
@@ -232,11 +232,11 @@ struct User : Codable {
232232    let  name: String 
233233    let  bestFriendID: Int 
234234    let  friendIDs: [Int ]
235-      
235+ 
236236    func  getBestFriend (context arguments group throws  ->  EventLoopFuture<User> {
237237        return  try  context.userLoader .load (key : user.bestFriendID , on : group)
238238    }
239-      
239+ 
240240    struct  FriendArguments  {
241241        first:  Int 
242242    }
@@ -273,7 +273,7 @@ struct UserAPI : API {
273273                Argument (" first" at : .\first)
274274            }
275275        }
276-          
276+ 
277277        Query  {
278278            Field (" me" at : UserResolver.hero , as : User.self )
279279        }
@@ -301,6 +301,6 @@ swiftformat .
301301
302302## Acknowledgements 👏  
303303
304- This library is entirely a Swift version of Facebooks [ DataLoader] ( https://github.com/facebook/dataloader ) .  
305- Developed by  [ Lee Byron] ( https://github.com/leebyron )  and [ Nicholas Schrock] ( https://github.com/schrockn )   
304+ This library is entirely a Swift version of Facebooks [ DataLoader] ( https://github.com/facebook/dataloader ) .
305+ Developed by  [ Lee Byron] ( https://github.com/leebyron )  and [ Nicholas Schrock] ( https://github.com/schrockn ) 
306306from [ Facebook] ( https://www.facebook.com/ ) .
0 commit comments