16
16
17
17
#import < Foundation/Foundation.h>
18
18
19
+ // if adding data store data type, update: removeSavedEvents
19
20
typedef NS_ENUM (NSUInteger , OPTLYDataStoreDataType)
20
21
{
21
22
OPTLYDataStoreDataTypeDatabase,
@@ -24,7 +25,7 @@ typedef NS_ENUM(NSUInteger, OPTLYDataStoreDataType)
24
25
OPTLYDataStoreDataTypeUserProfile,
25
26
};
26
27
27
- // if adding event type, update: removeAllUserData!!
28
+ // if adding event type, update: removeAllUserData
28
29
typedef NS_ENUM (NSUInteger , OPTLYDataStoreEventType)
29
30
{
30
31
OPTLYDataStoreEventTypeImpression,
@@ -50,7 +51,7 @@ typedef NS_ENUM(NSUInteger, OPTLYDataStoreEventType)
50
51
* Wipes all Optimizely data (saved and cached).
51
52
*
52
53
**/
53
- - (void )removeAll ;
54
+ - (void )removeAll : ( NSError * _Nullable * _Nullable) error ;
54
55
55
56
// -------- File Storage --------
56
57
// Persists data in a file format using NSFileManager.
@@ -144,116 +145,123 @@ typedef NS_ENUM(NSUInteger, OPTLYDataStoreEventType)
144
145
// If data is cached, then the events are stored in a runtime in-memory queue.
145
146
// If data is not cached, the events are stored in an SQLite table.
146
147
// Events are only persisted in the SQLite table for iOS platforms.
147
- // tvOS events are only cached to save on very limited memory usage .
148
- // A future enhancement for tvOS is to store data in iCloud.
148
+ // tvOS events are only cached to save on very limited memory availability .
149
+ // A future enhancement for tvOS is to store event data in iCloud.
149
150
150
151
/* *
151
152
* Saves an event.
152
153
*
153
154
* @param data The data to be saved.
154
155
* @param eventType The event type of the data that needs to be saved.
155
- * @param cacheData Specify if the data should be cached (default is true for tvOS).
156
+ * @param cachedData Specify if the data should be saved in the in-memory
157
+ * cache and not saved in the database (this is always true for tvOS).
156
158
* @param error An error object is returned if an error occurs.
157
159
*/
158
160
- (void )saveData : (nonnull NSDictionary *)data
159
161
eventType : (OPTLYDataStoreEventType)eventType
160
- cacheData : (bool )cacheData
162
+ cachedData : (bool )cachedData
161
163
error : (NSError * _Nullable * _Nullable)error ;
162
164
163
165
/* *
164
166
* Gets the oldest event.
165
167
*
166
168
* @param eventType The event type of the data that needs to be retrieved.
167
- * @param cacheData Specify if the data should be retrieved from cache (this is by default always true for tvOS).
169
+ * @param cachedData Specify if the data should be retrieved from the in-memory
170
+ * cache and not saved in the database (this is always true for tvOS).
168
171
* @param error An error object is returned if an error occurs.
169
172
*/
170
173
- (nullable NSDictionary *)getOldestEvent : (OPTLYDataStoreEventType)eventType
171
- cacheData : (bool )cacheData
174
+ cachedData : (bool )cachedData
172
175
error : (NSError * _Nullable * _Nullable)error ;
173
176
174
177
/* *
175
178
* Gets the first N entries (i.e., the N oldest events).
176
179
*
177
180
* @param numberOfEvents The number of events to retrieve.
178
181
* @param eventType The event type of the data that needs to be removed.
179
- * @param cacheData Specify if the data should be retrieved from cache (this is by default always true for tvOS).
182
+ * @param cachedData Specify if the data should be retrieved from the in-memory
183
+ * cache and not saved in the database (this is always true for tvOS).
180
184
* @param error An error object is returned if an error occurs.
181
185
*/
182
186
- (nullable NSArray *)getFirstNEvents : (NSInteger )numberOfEvents
183
187
eventType : (OPTLYDataStoreEventType)eventType
184
- cacheData : (bool )cacheData
188
+ cachedData : (bool )cachedData
185
189
error : (NSError * _Nullable * _Nullable)error ;
186
190
187
191
/* *
188
192
* Gets all events.
189
193
*
190
194
* @param eventType The event type of the data that needs to be retrieved.
191
- * @param cacheData Specify if the data should be retrieved from cache (this is by default always true for tvOS).
195
+ * @param cachedData Specify if the data should be retrieved from the in-memory
196
+ * cache and not saved in the database (this is always true for tvOS).
192
197
* @param error An error object is returned if an error occurs.
193
198
* @return The return value is an array of OPTLYDatabaseEntity.
194
199
*/
195
200
- (nullable NSArray *)getAllEvents : (OPTLYDataStoreEventType)eventType
196
- cacheData : (bool )cacheData
201
+ cachedData : (bool )cachedData
197
202
error : (NSError * _Nullable * _Nullable)error ;
198
203
199
204
/* *
200
205
* Deletes the oldest event.
201
206
*
202
207
* @param eventType The event type of the data that needs to be removed.
203
- * @param cacheData Specify if the data should be removed from cache (this is by default always true for tvOS).
208
+ * @param cachedData Specify if the data should be deleted from the in-memory
209
+ * cache and not saved in the database (this is always true for tvOS).
204
210
* @param error An error object is returned if an error occurs.
205
211
*/
206
212
- (void )removeOldestEvent : (OPTLYDataStoreEventType)eventType
207
- cacheData : (bool )cacheData
213
+ cachedData : (bool )cachedData
208
214
error : (NSError * _Nullable * _Nullable)error ;
209
215
210
216
/* *
211
217
* Deletes the first N events (i.e., the N oldest events).
212
218
*
213
219
* @param numberOfEvents The number of events to retrieve.
214
220
* @param eventType The event type of the data that needs to be removed.
215
- * @param cacheData Specify if the data should be removed from cache (this is by default always true for tvOS).
221
+ * @param cachedData Specify if the data should be deleted from the in-memory
222
+ * cache and not saved in the database (this is always true for tvOS).
216
223
* @param error An error object is returned if an error occurs.
217
224
*/
218
225
- (void )removeFirstNEvents : (NSInteger )numberOfEvents
219
226
eventType : (OPTLYDataStoreEventType)eventType
220
- cacheData : (bool )cacheData
227
+ cachedData : (bool )cachedData
221
228
error : (NSError * _Nullable * _Nullable)error ;
222
229
223
230
/* *
224
231
* Deletes all events.
225
232
*
226
233
* @param eventType The event type of the data that needs to be removed.
227
- * @param cacheData Specify if the data should be removed from cache (this is by default always true for tvOS).
234
+ * @param cachedData Specify if the data should be deleted from the in-memory
235
+ * cache and not saved in the database (this is always true for tvOS).
228
236
* @param error An error object is returned if an error occurs.
229
237
*/
230
238
- (void )removeAllEvents : (OPTLYDataStoreEventType)eventType
231
- cacheData : (bool )cacheData
239
+ cachedData : (bool )cachedData
232
240
error : (NSError * _Nullable * _Nullable)error ;
233
241
234
242
/* *
235
243
* Returns the number of saved events.
236
244
*
237
245
* @param eventType The event type of the data.
238
- * @param cacheData Specify if the event count should be retrieved from cache (this is by default always true for tvOS).
246
+ * @param cachedData Specify if the data should be retrieved from the in-memory
247
+ * cache and not saved in the database (this is always true for tvOS).
239
248
* @param error An error object is returned if an error occurs.
240
249
* @return The number of events saved.
241
250
*/
242
251
- (NSInteger )numberOfEvents : (OPTLYDataStoreEventType)eventType
243
- cacheData : (bool )cacheData
252
+ cachedData : (bool )cachedData
244
253
error : (NSError * _Nullable * _Nullable)error ;
245
254
246
255
/* *
247
- * Removes all cached events.
248
- */
249
- - (void )removeCachedEvents ;
250
-
251
- /* *
252
- * Removes all saved events.
256
+ * Removes all saved or cached events.
253
257
*
258
+ * @param cachedData Specify if the data should be deleted from the in-memory
259
+ * cache and not saved in the database (this is always true for tvOS).
254
260
* @param error An error object is returned if an error occurs.
255
261
*/
256
- - (void )removeSavedEvents : (NSError * _Nullable * _Nullable)error ;
262
+ - (void )removeSavedEvents : (BOOL )cachedData
263
+ error : (NSError * _Nullable * _Nullable)error ;
264
+
257
265
258
266
// -------- User Data Storage --------
259
267
// Saves data in dictionary format in NSUserDefault
0 commit comments