RCTAsyncLocalStorage.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * Copyright (c) Facebook, Inc. and its 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. #import <React/RCTBridgeModule.h>
  8. #import <React/RCTInvalidating.h>
  9. /**
  10. * A simple, asynchronous, persistent, key-value storage system designed as a
  11. * backend to the AsyncStorage JS module, which is modeled after LocalStorage.
  12. *
  13. * Current implementation stores small values in serialized dictionary and
  14. * larger values in separate files. Since we use a serial file queue
  15. * `RKFileQueue`, reading/writing from multiple threads should be perceived as
  16. * being atomic, unless someone bypasses the `RCTAsyncLocalStorage` API.
  17. *
  18. * Keys and values must always be strings or an error is returned.
  19. */
  20. @interface RCTAsyncLocalStorage : NSObject <RCTBridgeModule,RCTInvalidating>
  21. @property (nonatomic, assign) BOOL clearOnInvalidate;
  22. @property (nonatomic, readonly, getter=isValid) BOOL valid;
  23. // Clear the RCTAsyncLocalStorage data from native code
  24. - (void)clearAllData;
  25. // For clearing data when the bridge may not exist, e.g. when logging out.
  26. + (void)clearAllData;
  27. // Grab data from the cache. ResponseBlock result array will have an error at position 0, and an array of arrays at position 1.
  28. - (void)multiGet:(NSArray<NSString *> *)keys callback:(RCTResponseSenderBlock)callback;
  29. // Add multiple key value pairs to the cache.
  30. - (void)multiSet:(NSArray<NSArray<NSString *> *> *)kvPairs callback:(RCTResponseSenderBlock)callback;
  31. @end