1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #import <ABI47_0_0React/ABI47_0_0RCTBridgeModule.h>
9 #import <ABI47_0_0React/ABI47_0_0RCTInvalidating.h>
10 
11 /**
12  * A simple, asynchronous, persistent, key-value storage system designed as a
13  * backend to the AsyncStorage JS module, which is modeled after LocalStorage.
14  *
15  * Current implementation stores small values in serialized dictionary and
16  * larger values in separate files. Since we use a serial file queue
17  * `RKFileQueue`, reading/writing from multiple threads should be perceived as
18  * being atomic, unless someone bypasses the `ABI47_0_0RCTAsyncLocalStorage` API.
19  *
20  * Keys and values must always be strings or an error is returned.
21  */
22 @interface ABI47_0_0RCTAsyncLocalStorage : NSObject <ABI47_0_0RCTBridgeModule, ABI47_0_0RCTInvalidating>
23 
24 @property (nonatomic, assign) BOOL clearOnInvalidate;
25 
26 @property (nonatomic, readonly, getter=isValid) BOOL valid;
27 
28 // NOTE(nikki): Added to allow scoped per Expo app
29 - (instancetype)initWithStorageDirectory:(NSString *)storageDirectory;
30 
31 // Clear the ABI47_0_0RCTAsyncLocalStorage data from native code
32 - (void)clearAllData;
33 
34 // Grab data from the cache. ResponseBlock result array will have an error at position 0, and an array of arrays at position 1.
35 - (void)multiGet:(NSArray<NSString *> *)keys callback:(ABI47_0_0RCTResponseSenderBlock)callback;
36 
37 // Add multiple key value pairs to the cache.
38 - (void)multiSet:(NSArray<NSArray<NSString *> *> *)kvPairs callback:(ABI47_0_0RCTResponseSenderBlock)callback;
39 
40 @end
41