motion-yapper 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (296) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -2
  3. data/.travis.yml +2 -0
  4. data/Gemfile +1 -0
  5. data/README.md +1 -1
  6. data/Rakefile +1 -1
  7. data/lib/motion-yapper.rb +1 -0
  8. data/lib/yapper.rb +3 -5
  9. data/lib/yapper/config.rb +2 -0
  10. data/lib/yapper/db.rb +105 -40
  11. data/lib/yapper/document.rb +7 -4
  12. data/lib/yapper/document/callbacks.rb +0 -7
  13. data/lib/yapper/document/{persistance.rb → persistence.rb} +27 -21
  14. data/lib/yapper/document/relation.rb +29 -22
  15. data/lib/yapper/document/selection.rb +122 -54
  16. data/lib/yapper/extensions.rb +12 -24
  17. data/lib/yapper/settings.rb +43 -0
  18. data/lib/yapper/timestamps.rb +2 -0
  19. data/lib/yapper/version.rb +1 -1
  20. data/{yapper.gemspec → motion-yapper.gemspec} +0 -0
  21. data/spec/integration/{where_spec.rb → criteria_spec.rb} +78 -10
  22. data/spec/integration/db_spec.rb +70 -0
  23. data/spec/integration/defaults_spec.rb +37 -0
  24. data/spec/integration/extensions_spec.rb +14 -0
  25. data/spec/integration/{persistance_spec.rb → persistence_spec.rb} +0 -0
  26. data/spec/integration/relation_spec.rb +4 -4
  27. data/vendor/Podfile.lock +9 -11
  28. data/vendor/Pods/.build/libPods-CocoaLumberjack.a +0 -0
  29. data/vendor/Pods/.build/libPods-NSData+MD5Digest.a +0 -0
  30. data/vendor/Pods/.build/libPods-YapDatabase.a +0 -0
  31. data/vendor/Pods/.build/libPods.a +0 -0
  32. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDASLLogger.h +4 -4
  33. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDAbstractDatabaseLogger.h +14 -14
  34. data/vendor/Pods/{CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.h → BuildHeaders/CocoaLumberjack/DDContextFilterLogFormatter.h} +6 -8
  35. data/vendor/Pods/BuildHeaders/CocoaLumberjack/{DispatchQueueLogFormatter.h → DDDispatchQueueLogFormatter.h} +18 -6
  36. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDFileLogger.h +67 -32
  37. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog+LOGV.h +99 -0
  38. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog.h +98 -65
  39. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDMultiFormatter.h +30 -0
  40. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDTTYLogger.h +39 -25
  41. data/vendor/Pods/BuildHeaders/YapDatabase/NSDictionary+YapDatabase.h +8 -0
  42. data/vendor/Pods/BuildHeaders/YapDatabase/YapCache.h +1 -0
  43. data/vendor/Pods/BuildHeaders/YapDatabase/YapCollectionKey.h +3 -0
  44. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabase.h +4 -4
  45. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnection.h +21 -19
  46. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseDefaults.h +1 -1
  47. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionPrivate.h +35 -31
  48. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredView.h +8 -35
  49. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewPrivate.h +0 -2
  50. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTransaction.h +17 -17
  51. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTypes.h +32 -0
  52. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchPrivate.h +8 -0
  53. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabasePrivate.h +43 -21
  54. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationship.h +35 -0
  55. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipConnection.h +29 -0
  56. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipEdge.h +163 -0
  57. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipEdgePrivate.h +79 -0
  58. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipNode.h +99 -0
  59. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipOptions.h +59 -0
  60. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipPrivate.h +125 -0
  61. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipTransaction.h +384 -0
  62. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndex.h +49 -0
  63. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +10 -0
  64. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexSetupPrivate.h +18 -0
  65. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseTransaction.h +131 -21
  66. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseView.h +48 -107
  67. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChange.h +2 -2
  68. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewConnection.h +1 -0
  69. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappings.h +17 -0
  70. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewOptions.h +10 -3
  71. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPrivate.h +18 -1
  72. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTransaction.h +75 -24
  73. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTypes.h +99 -0
  74. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.h +4 -4
  75. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m +51 -50
  76. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.h +14 -14
  77. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m +546 -546
  78. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.h +67 -32
  79. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.m +1093 -907
  80. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog+LOGV.h +99 -0
  81. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.h +98 -65
  82. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.m +873 -748
  83. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.h +39 -25
  84. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.m +1284 -1243
  85. data/vendor/Pods/{BuildHeaders/CocoaLumberjack/ContextFilterLogFormatter.h → CocoaLumberjack/Lumberjack/Extensions/DDContextFilterLogFormatter.h} +6 -8
  86. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/{ContextFilterLogFormatter.m → DDContextFilterLogFormatter.m} +70 -70
  87. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/{DispatchQueueLogFormatter.h → DDDispatchQueueLogFormatter.h} +18 -6
  88. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDDispatchQueueLogFormatter.m +253 -0
  89. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDMultiFormatter.h +30 -0
  90. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDMultiFormatter.m +127 -0
  91. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/README.txt +1 -1
  92. data/vendor/Pods/CocoaLumberjack/README.markdown +52 -15
  93. data/vendor/Pods/Headers/CocoaLumberjack/DDASLLogger.h +4 -4
  94. data/vendor/Pods/Headers/CocoaLumberjack/DDAbstractDatabaseLogger.h +14 -14
  95. data/vendor/Pods/Headers/CocoaLumberjack/{ContextFilterLogFormatter.h → DDContextFilterLogFormatter.h} +6 -8
  96. data/vendor/Pods/Headers/CocoaLumberjack/{DispatchQueueLogFormatter.h → DDDispatchQueueLogFormatter.h} +18 -6
  97. data/vendor/Pods/Headers/CocoaLumberjack/DDFileLogger.h +67 -32
  98. data/vendor/Pods/Headers/CocoaLumberjack/DDLog+LOGV.h +99 -0
  99. data/vendor/Pods/Headers/CocoaLumberjack/DDLog.h +98 -65
  100. data/vendor/Pods/Headers/CocoaLumberjack/DDMultiFormatter.h +30 -0
  101. data/vendor/Pods/Headers/CocoaLumberjack/DDTTYLogger.h +39 -25
  102. data/vendor/Pods/Headers/YapDatabase/YapCollectionKey.h +3 -0
  103. data/vendor/Pods/Headers/YapDatabase/YapDatabase.h +4 -4
  104. data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnection.h +21 -19
  105. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredView.h +8 -35
  106. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTransaction.h +17 -17
  107. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTypes.h +32 -0
  108. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationship.h +35 -0
  109. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipConnection.h +29 -0
  110. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipEdge.h +163 -0
  111. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipNode.h +99 -0
  112. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipOptions.h +59 -0
  113. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipTransaction.h +384 -0
  114. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndex.h +49 -0
  115. data/vendor/Pods/Headers/YapDatabase/YapDatabaseTransaction.h +131 -21
  116. data/vendor/Pods/Headers/YapDatabase/YapDatabaseView.h +48 -107
  117. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChange.h +2 -2
  118. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewConnection.h +1 -0
  119. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappings.h +17 -0
  120. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewOptions.h +10 -3
  121. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTransaction.h +75 -24
  122. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTypes.h +99 -0
  123. data/vendor/Pods/Headers/____Pods-CocoaLumberjack-prefix.h +2 -0
  124. data/vendor/Pods/Headers/____Pods-environment.h +15 -15
  125. data/vendor/Pods/Manifest.lock +9 -11
  126. data/vendor/Pods/Pods-CocoaLumberjack-Private.xcconfig +1 -1
  127. data/vendor/Pods/Pods-CocoaLumberjack-prefix.pch +2 -0
  128. data/vendor/Pods/Pods-NSData+MD5Digest-Private.xcconfig +1 -1
  129. data/vendor/Pods/Pods-YapDatabase-Private.xcconfig +1 -1
  130. data/vendor/Pods/{Pods-Acknowledgements.markdown → Pods-acknowledgements.markdown} +0 -37
  131. data/vendor/Pods/{Pods-Acknowledgements.plist → Pods-acknowledgements.plist} +0 -45
  132. data/vendor/Pods/Pods-environment.h +15 -15
  133. data/vendor/Pods/Pods.xcconfig +3 -3
  134. data/vendor/Pods/Pods.xcodeproj/project.pbxproj +2426 -3155
  135. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-CocoaLumberjack.xcscheme +59 -0
  136. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-NSData+MD5Digest.xcscheme +59 -0
  137. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-YapDatabase.xcscheme +59 -0
  138. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods.xcscheme +59 -0
  139. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/xcschememanagement.plist +31 -0
  140. data/vendor/Pods/YapDatabase/README.md +3 -1
  141. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/Internal/YapDatabaseFilteredViewPrivate.h +0 -2
  142. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.h +8 -35
  143. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.m +25 -41
  144. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.h +17 -17
  145. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.m +403 -134
  146. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTypes.h +32 -0
  147. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/Internal/YapDatabaseFullTextSearchPrivate.h +8 -0
  148. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.m +8 -8
  149. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.m +113 -62
  150. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/Internal/YapDatabaseExtensionPrivate.h +35 -31
  151. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.m +25 -0
  152. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.m +1 -1
  153. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.m +25 -1
  154. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/Internal/YapDatabaseRelationshipEdgePrivate.h +79 -0
  155. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/Internal/YapDatabaseRelationshipPrivate.h +125 -0
  156. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationship.h +35 -0
  157. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationship.m +129 -0
  158. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipConnection.h +29 -0
  159. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipConnection.m +802 -0
  160. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipEdge.h +163 -0
  161. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipEdge.m +408 -0
  162. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipNode.h +99 -0
  163. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipOptions.h +59 -0
  164. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipOptions.m +29 -0
  165. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipTransaction.h +384 -0
  166. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipTransaction.m +5254 -0
  167. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexPrivate.h +10 -0
  168. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexSetupPrivate.h +18 -0
  169. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.h +49 -0
  170. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.m +12 -0
  171. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.m +9 -8
  172. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.m +62 -1
  173. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.m +148 -45
  174. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPrivate.h +18 -1
  175. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.h +2 -2
  176. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.m +15 -9
  177. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.h +17 -0
  178. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.m +211 -64
  179. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.h +48 -107
  180. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.m +10 -7
  181. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.h +1 -0
  182. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.m +13 -22
  183. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.h +10 -3
  184. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.h +75 -24
  185. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.m +725 -244
  186. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTypes.h +99 -0
  187. data/vendor/Pods/YapDatabase/YapDatabase/Internal/NSDictionary+YapDatabase.h +8 -0
  188. data/vendor/Pods/YapDatabase/YapDatabase/Internal/NSDictionary+YapDatabase.m +19 -0
  189. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.h +1 -0
  190. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.m +12 -0
  191. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.h +1 -1
  192. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.m +3 -3
  193. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabasePrivate.h +43 -21
  194. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.m +4 -0
  195. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.h +3 -0
  196. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.m +5 -0
  197. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.h +4 -4
  198. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.m +84 -93
  199. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.h +21 -19
  200. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.m +381 -209
  201. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.h +131 -21
  202. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.m +587 -267
  203. data/vendor/Pods/{Pods.bridgesupport → build-iPhoneSimulator/Pods.bridgesupport} +633 -2557
  204. data/vendor/Pods/build-iPhoneSimulator/libPods.a +0 -0
  205. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.bridgesupport +2 -1
  206. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.h +2 -1
  207. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.m +4 -2
  208. metadata +80 -108
  209. data/Gemfile.lock +0 -63
  210. data/lib/yapper/attachment.rb +0 -48
  211. data/lib/yapper/document/attachment.rb +0 -26
  212. data/lib/yapper/sync.rb +0 -134
  213. data/lib/yapper/sync/data.rb +0 -12
  214. data/lib/yapper/sync/event.rb +0 -194
  215. data/lib/yapper/sync/queue.rb +0 -164
  216. data/spec/integration/all_spec.rb +0 -40
  217. data/spec/integration/sync_spec.rb +0 -42
  218. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.h +0 -641
  219. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.m +0 -1396
  220. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h +0 -133
  221. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m +0 -327
  222. data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.h +0 -113
  223. data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.m +0 -321
  224. data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.h +0 -71
  225. data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.m +0 -150
  226. data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
  227. data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.m +0 -157
  228. data/vendor/Pods/AFNetworking/AFNetworking/AFNetworking.h +0 -43
  229. data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.h +0 -68
  230. data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.m +0 -143
  231. data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h +0 -370
  232. data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m +0 -848
  233. data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.h +0 -89
  234. data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.m +0 -167
  235. data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.h +0 -78
  236. data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.m +0 -191
  237. data/vendor/Pods/AFNetworking/LICENSE +0 -19
  238. data/vendor/Pods/AFNetworking/README.md +0 -208
  239. data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPClient.h +0 -641
  240. data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPRequestOperation.h +0 -133
  241. data/vendor/Pods/BuildHeaders/AFNetworking/AFImageRequestOperation.h +0 -113
  242. data/vendor/Pods/BuildHeaders/AFNetworking/AFJSONRequestOperation.h +0 -71
  243. data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
  244. data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworking.h +0 -43
  245. data/vendor/Pods/BuildHeaders/AFNetworking/AFPropertyListRequestOperation.h +0 -68
  246. data/vendor/Pods/BuildHeaders/AFNetworking/AFURLConnectionOperation.h +0 -370
  247. data/vendor/Pods/BuildHeaders/AFNetworking/AFXMLRequestOperation.h +0 -89
  248. data/vendor/Pods/BuildHeaders/AFNetworking/UIImageView+AFNetworking.h +0 -78
  249. data/vendor/Pods/BuildHeaders/Reachability/Reachability.h +0 -109
  250. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.m +0 -251
  251. data/vendor/Pods/Headers/AFNetworking/AFHTTPClient.h +0 -641
  252. data/vendor/Pods/Headers/AFNetworking/AFHTTPRequestOperation.h +0 -133
  253. data/vendor/Pods/Headers/AFNetworking/AFImageRequestOperation.h +0 -113
  254. data/vendor/Pods/Headers/AFNetworking/AFJSONRequestOperation.h +0 -71
  255. data/vendor/Pods/Headers/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
  256. data/vendor/Pods/Headers/AFNetworking/AFNetworking.h +0 -43
  257. data/vendor/Pods/Headers/AFNetworking/AFPropertyListRequestOperation.h +0 -68
  258. data/vendor/Pods/Headers/AFNetworking/AFURLConnectionOperation.h +0 -370
  259. data/vendor/Pods/Headers/AFNetworking/AFXMLRequestOperation.h +0 -89
  260. data/vendor/Pods/Headers/AFNetworking/UIImageView+AFNetworking.h +0 -78
  261. data/vendor/Pods/Headers/Reachability/Reachability.h +0 -109
  262. data/vendor/Pods/Headers/YapDatabase/YapCache.h +0 -90
  263. data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnectionState.h +0 -29
  264. data/vendor/Pods/Headers/YapDatabase/YapDatabaseDefaults.h +0 -37
  265. data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionPrivate.h +0 -440
  266. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewPrivate.h +0 -19
  267. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchPrivate.h +0 -69
  268. data/vendor/Pods/Headers/YapDatabase/YapDatabaseLogging.h +0 -158
  269. data/vendor/Pods/Headers/YapDatabase/YapDatabaseManager.h +0 -17
  270. data/vendor/Pods/Headers/YapDatabase/YapDatabasePrivate.h +0 -424
  271. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +0 -73
  272. data/vendor/Pods/Headers/YapDatabase/YapDatabaseStatement.h +0 -13
  273. data/vendor/Pods/Headers/YapDatabase/YapDatabaseString.h +0 -121
  274. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChangePrivate.h +0 -94
  275. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappingsPrivate.h +0 -72
  276. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPage.h +0 -36
  277. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPageMetadata.h +0 -27
  278. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPrivate.h +0 -153
  279. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +0 -17
  280. data/vendor/Pods/Headers/YapDatabase/YapMemoryTable.h +0 -74
  281. data/vendor/Pods/Headers/YapDatabase/YapNull.h +0 -17
  282. data/vendor/Pods/Headers/YapDatabase/YapTouch.h +0 -15
  283. data/vendor/Pods/Headers/____Pods-AFNetworking-prefix.h +0 -17
  284. data/vendor/Pods/Headers/____Pods-Reachability-prefix.h +0 -5
  285. data/vendor/Pods/Pods-AFNetworking-Private.xcconfig +0 -5
  286. data/vendor/Pods/Pods-AFNetworking-dummy.m +0 -5
  287. data/vendor/Pods/Pods-AFNetworking-prefix.pch +0 -17
  288. data/vendor/Pods/Pods-AFNetworking.xcconfig +0 -1
  289. data/vendor/Pods/Pods-Reachability-Private.xcconfig +0 -5
  290. data/vendor/Pods/Pods-Reachability-dummy.m +0 -5
  291. data/vendor/Pods/Pods-Reachability-prefix.pch +0 -5
  292. data/vendor/Pods/Pods-Reachability.xcconfig +0 -1
  293. data/vendor/Pods/Reachability/LICENCE.txt +0 -24
  294. data/vendor/Pods/Reachability/README.md +0 -65
  295. data/vendor/Pods/Reachability/Reachability.h +0 -109
  296. data/vendor/Pods/Reachability/Reachability.m +0 -527
@@ -29,12 +29,14 @@
29
29
  * But for conncurrent access between multiple threads you must use multiple connections.
30
30
  **/
31
31
 
32
- typedef enum {
33
- YapDatabaseConnectionFlushMemoryLevelNone = 0,
34
- YapDatabaseConnectionFlushMemoryLevelMild = 1,
35
- YapDatabaseConnectionFlushMemoryLevelModerate = 2,
36
- YapDatabaseConnectionFlushMemoryLevelFull = 3,
37
- } YapDatabaseConnectionFlushMemoryLevel;
32
+ enum {
33
+ YapDatabaseConnectionFlushMemoryFlags_None = 0,
34
+ YapDatabaseConnectionFlushMemoryFlags_Caches = 1 << 0,
35
+ YapDatabaseConnectionFlushMemoryFlags_Statements = 1 << 1,
36
+ YapDatabaseConnectionFlushMemoryFlags_All = (YapDatabaseConnectionFlushMemoryFlags_Caches |
37
+ YapDatabaseConnectionFlushMemoryFlags_Statements),
38
+ };
39
+ typedef int YapDatabaseConnectionFlushMemoryFlags;
38
40
 
39
41
  typedef enum {
40
42
  YapDatabasePolicyContainment = 0,
@@ -418,30 +420,30 @@ typedef enum {
418
420
  * Depending upon how often you use the database connection,
419
421
  * you may want to be more or less aggressive on how much stuff you flush.
420
422
  *
421
- * YapDatabaseConnectionFlushMemoryLevelNone (0):
422
- * No-op. Doesn't flush any caches or anything from internal memory.
423
+ * YapDatabaseConnectionFlushMemoryFlags_None:
424
+ * No-op. Doesn't flush anything.
423
425
  *
424
- * YapDatabaseConnectionFlushMemoryLevelMild (1):
425
- * Flushes the object cache and metadata cache.
426
+ * YapDatabaseConnectionFlushMemoryFlags_Caches:
427
+ * Flushes all caches, including the object cache and metadata cache.
426
428
  *
427
- * YapDatabaseConnectionFlushMemoryLevelModerate (2):
428
- * Mild plus drops less common pre-compiled sqlite statements.
429
+ * YapDatabaseConnectionFlushMemoryFlags_Statements:
430
+ * Flushes all pre-compiled sqlite statements.
429
431
  *
430
- * YapDatabaseConnectionFlushMemoryLevelFull (3):
431
- * Full flush of all caches and removes all pre-compiled sqlite statements.
432
+ * YapDatabaseConnectionFlushMemoryFlags_All:
433
+ * Full flush of all caches and pre-compiled sqlite statements.
432
434
  **/
433
- - (void)flushMemoryWithLevel:(int)level;
435
+ - (void)flushMemoryWithFlags:(YapDatabaseConnectionFlushMemoryFlags)flags;
434
436
 
435
437
  #if TARGET_OS_IPHONE
436
438
  /**
437
439
  * When a UIApplicationDidReceiveMemoryWarningNotification is received,
438
- * the code automatically invokes flushMemoryWithLevel and passes this set level.
440
+ * the code automatically invokes flushMemoryWithFlags and passes the set flags.
439
441
  *
440
- * The default value is YapDatabaseConnectionFlushMemoryLevelMild.
442
+ * The default value is YapDatabaseConnectionFlushMemoryFlags_All.
441
443
  *
442
- * @see flushMemoryWithLevel:
444
+ * @see flushMemoryWithFlags:
443
445
  **/
444
- @property (atomic, assign, readwrite) int autoFlushMemoryLevel;
446
+ @property (atomic, assign, readwrite) YapDatabaseConnectionFlushMemoryFlags autoFlushMemoryFlags;
445
447
  #endif
446
448
 
447
449
  @end
@@ -29,6 +29,8 @@
29
29
  static const int ydbLogLevel = YDB_LOG_LEVEL_WARN;
30
30
  #endif
31
31
 
32
+ #define UNLIMITED_CACHE_LIMIT 0
33
+ #define MIN_KEY_CACHE_LIMIT 500
32
34
  #define DEFAULT_OBJECT_CACHE_LIMIT 250
33
35
  #define DEFAULT_METADATA_CACHE_LIMIT 500
34
36
 
@@ -42,6 +44,7 @@
42
44
 
43
45
  sqlite3_stmt *yapGetDataForKeyStatement; // Against "yap" database, for internal use
44
46
  sqlite3_stmt *yapSetDataForKeyStatement; // Against "yap" database, for internal use
47
+ sqlite3_stmt *yapRemoveForKeyStatement; // Against "yap" database, for internal use
45
48
  sqlite3_stmt *yapRemoveExtensionStatement; // Against "yap" database, for internal use
46
49
 
47
50
  sqlite3_stmt *getCollectionCountStatement;
@@ -50,15 +53,15 @@
50
53
  sqlite3_stmt *getCountForRowidStatement;
51
54
  sqlite3_stmt *getRowidForKeyStatement;
52
55
  sqlite3_stmt *getKeyForRowidStatement;
53
- sqlite3_stmt *getKeyDataForRowidStatement;
54
- sqlite3_stmt *getKeyMetadataForRowidStatement;
55
56
  sqlite3_stmt *getDataForRowidStatement;
57
+ sqlite3_stmt *getMetadataForRowidStatement;
56
58
  sqlite3_stmt *getAllForRowidStatement;
57
59
  sqlite3_stmt *getDataForKeyStatement;
58
60
  sqlite3_stmt *getMetadataForKeyStatement;
59
61
  sqlite3_stmt *getAllForKeyStatement;
60
62
  sqlite3_stmt *insertForRowidStatement;
61
63
  sqlite3_stmt *updateAllForRowidStatement;
64
+ sqlite3_stmt *updateObjectForRowidStatement;
62
65
  sqlite3_stmt *updateMetadataForRowidStatement;
63
66
  sqlite3_stmt *removeForRowidStatement;
64
67
  sqlite3_stmt *removeCollectionStatement;
@@ -123,21 +126,41 @@
123
126
 
124
127
  YapDatabaseDefaults *defaults = [database defaults];
125
128
 
129
+ NSUInteger keyCacheLimit = MIN_KEY_CACHE_LIMIT;
130
+
126
131
  if (defaults.objectCacheEnabled)
127
132
  {
128
133
  objectCacheLimit = defaults.objectCacheLimit;
129
134
  objectCache = [[YapCache alloc] initWithKeyClass:[YapCollectionKey class]];
130
135
  objectCache.countLimit = objectCacheLimit;
136
+
137
+ if (keyCacheLimit != UNLIMITED_CACHE_LIMIT)
138
+ {
139
+ if (objectCacheLimit == UNLIMITED_CACHE_LIMIT)
140
+ keyCacheLimit = UNLIMITED_CACHE_LIMIT;
141
+ else
142
+ keyCacheLimit = MAX(keyCacheLimit, objectCacheLimit);
143
+ }
131
144
  }
132
145
  if (defaults.metadataCacheEnabled)
133
146
  {
134
147
  metadataCacheLimit = defaults.metadataCacheLimit;
135
148
  metadataCache = [[YapCache alloc] initWithKeyClass:[YapCollectionKey class]];
136
149
  metadataCache.countLimit = metadataCacheLimit;
150
+
151
+ if (keyCacheLimit != UNLIMITED_CACHE_LIMIT)
152
+ {
153
+ if (metadataCacheLimit == UNLIMITED_CACHE_LIMIT)
154
+ keyCacheLimit = UNLIMITED_CACHE_LIMIT;
155
+ else
156
+ keyCacheLimit = MAX(keyCacheLimit, objectCacheLimit);
157
+ }
137
158
  }
138
159
 
160
+ keyCache = [[YapCache alloc] initWithKeyClass:[NSNumber class] countLimit:keyCacheLimit];
161
+
139
162
  #if TARGET_OS_IPHONE
140
- self.autoFlushMemoryLevel = defaults.autoFlushMemoryLevel;
163
+ self.autoFlushMemoryFlags = defaults.autoFlushMemoryFlags;
141
164
  #endif
142
165
 
143
166
  lock = OS_SPINLOCK_INIT;
@@ -214,6 +237,7 @@
214
237
  registeredExtensions = [database registeredExtensions];
215
238
  registeredTables = [database registeredTables];
216
239
  extensionsOrder = [database extensionsOrder];
240
+ extensionDependencies = [database extensionDependencies];
217
241
 
218
242
  extensionsReady = ([registeredExtensions count] == 0);
219
243
  }
@@ -240,12 +264,43 @@
240
264
 
241
265
  [extensions removeAllObjects];
242
266
 
267
+ [self _flushStatements];
268
+
269
+ if (db)
270
+ {
271
+ if (![database connectionPoolEnqueue:db])
272
+ {
273
+ int status = sqlite3_close(db);
274
+ if (status != SQLITE_OK)
275
+ {
276
+ YDBLogError(@"Error in sqlite_close: %d %s", status, sqlite3_errmsg(db));
277
+ }
278
+ }
279
+
280
+ db = NULL;
281
+ }
282
+
283
+ [database removeConnection:self];
284
+
285
+ #if !OS_OBJECT_USE_OBJC
286
+ if (connectionQueue)
287
+ dispatch_release(connectionQueue);
288
+ #endif
289
+ }
290
+
291
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
292
+ #pragma mark Memory
293
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
294
+
295
+ - (void)_flushStatements
296
+ {
243
297
  sqlite_finalize_null(&beginTransactionStatement);
244
298
  sqlite_finalize_null(&commitTransactionStatement);
245
299
  sqlite_finalize_null(&rollbackTransactionStatement);
246
300
 
247
301
  sqlite_finalize_null(&yapGetDataForKeyStatement);
248
302
  sqlite_finalize_null(&yapSetDataForKeyStatement);
303
+ sqlite_finalize_null(&yapRemoveForKeyStatement);
249
304
  sqlite_finalize_null(&yapRemoveExtensionStatement);
250
305
 
251
306
  sqlite_finalize_null(&getCollectionCountStatement);
@@ -254,13 +309,15 @@
254
309
  sqlite_finalize_null(&getCountForRowidStatement);
255
310
  sqlite_finalize_null(&getRowidForKeyStatement);
256
311
  sqlite_finalize_null(&getKeyForRowidStatement);
257
- sqlite_finalize_null(&getKeyDataForRowidStatement);
258
- sqlite_finalize_null(&getKeyMetadataForRowidStatement);
259
312
  sqlite_finalize_null(&getDataForRowidStatement);
313
+ sqlite_finalize_null(&getMetadataForRowidStatement);
260
314
  sqlite_finalize_null(&getAllForRowidStatement);
261
315
  sqlite_finalize_null(&getDataForKeyStatement);
316
+ sqlite_finalize_null(&getMetadataForKeyStatement);
317
+ sqlite_finalize_null(&getAllForKeyStatement);
262
318
  sqlite_finalize_null(&insertForRowidStatement);
263
319
  sqlite_finalize_null(&updateAllForRowidStatement);
320
+ sqlite_finalize_null(&updateObjectForRowidStatement);
264
321
  sqlite_finalize_null(&updateMetadataForRowidStatement);
265
322
  sqlite_finalize_null(&removeForRowidStatement);
266
323
  sqlite_finalize_null(&removeCollectionStatement);
@@ -275,91 +332,25 @@
275
332
  sqlite_finalize_null(&enumerateKeysAndObjectsInAllCollectionsStatement);
276
333
  sqlite_finalize_null(&enumerateRowsInCollectionStatement);
277
334
  sqlite_finalize_null(&enumerateRowsInAllCollectionsStatement);
278
-
279
- if (db)
280
- {
281
- if (![database connectionPoolEnqueue:db])
282
- {
283
- int status = sqlite3_close(db);
284
- if (status != SQLITE_OK)
285
- {
286
- YDBLogError(@"Error in sqlite_close: %d %s", status, sqlite3_errmsg(db));
287
- }
288
- }
289
-
290
- db = NULL;
291
- }
292
-
293
- [database removeConnection:self];
294
-
295
- #if !OS_OBJECT_USE_OBJC
296
- if (connectionQueue)
297
- dispatch_release(connectionQueue);
298
- #endif
299
335
  }
300
336
 
301
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
302
- #pragma mark Memory
303
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
304
-
305
- /**
306
- * Optional override hook.
307
- * Don't forget to invoke [super _flushMemoryWithLevel:level].
308
- **/
309
- - (void)_flushMemoryWithLevel:(int)level
337
+ - (void)_flushMemoryWithFlags:(YapDatabaseConnectionFlushMemoryFlags)flags
310
338
  {
311
- if (level >= YapDatabaseConnectionFlushMemoryLevelMild)
339
+ if (flags & YapDatabaseConnectionFlushMemoryFlags_Caches)
312
340
  {
341
+ [keyCache removeAllObjects];
313
342
  [objectCache removeAllObjects];
314
343
  [metadataCache removeAllObjects];
315
344
  }
316
345
 
317
- if (level >= YapDatabaseConnectionFlushMemoryLevelModerate)
318
- {
319
- sqlite_finalize_null(&yapRemoveExtensionStatement);
320
- sqlite_finalize_null(&rollbackTransactionStatement);
321
-
322
- sqlite_finalize_null(&getCollectionCountStatement);
323
- sqlite_finalize_null(&getKeyCountForCollectionStatement);
324
- sqlite_finalize_null(&getKeyCountForAllStatement);
325
- sqlite_finalize_null(&getCountForRowidStatement);
326
- sqlite_finalize_null(&getKeyForRowidStatement);
327
- sqlite_finalize_null(&getKeyDataForRowidStatement);
328
- sqlite_finalize_null(&getKeyMetadataForRowidStatement);
329
- sqlite_finalize_null(&getDataForRowidStatement);
330
- sqlite_finalize_null(&getAllForRowidStatement);
331
- sqlite_finalize_null(&updateMetadataForRowidStatement);
332
- sqlite_finalize_null(&removeForRowidStatement);
333
- sqlite_finalize_null(&removeCollectionStatement);
334
- sqlite_finalize_null(&removeAllStatement);
335
- sqlite_finalize_null(&enumerateCollectionsStatement);
336
- sqlite_finalize_null(&enumerateCollectionsForKeyStatement);
337
- sqlite_finalize_null(&enumerateKeysInCollectionStatement);
338
- sqlite_finalize_null(&enumerateKeysInAllCollectionsStatement);
339
- sqlite_finalize_null(&enumerateKeysAndMetadataInCollectionStatement);
340
- sqlite_finalize_null(&enumerateKeysAndMetadataInAllCollectionsStatement);
341
- sqlite_finalize_null(&enumerateKeysAndObjectsInCollectionStatement);
342
- sqlite_finalize_null(&enumerateKeysAndObjectsInAllCollectionsStatement);
343
- sqlite_finalize_null(&enumerateRowsInCollectionStatement);
344
- sqlite_finalize_null(&enumerateRowsInAllCollectionsStatement);
345
- }
346
-
347
- if (level >= YapDatabaseConnectionFlushMemoryLevelFull)
348
- {
349
- sqlite_finalize_null(&yapGetDataForKeyStatement);
350
- sqlite_finalize_null(&yapSetDataForKeyStatement);
351
- sqlite_finalize_null(&beginTransactionStatement);
352
- sqlite_finalize_null(&commitTransactionStatement);
353
-
354
- sqlite_finalize_null(&getRowidForKeyStatement);
355
- sqlite_finalize_null(&getDataForKeyStatement);
356
- sqlite_finalize_null(&insertForRowidStatement);
357
- sqlite_finalize_null(&updateAllForRowidStatement);
346
+ if (flags & YapDatabaseConnectionFlushMemoryFlags_Statements)
347
+ {
348
+ [self _flushStatements];
358
349
  }
359
350
 
360
351
  [extensions enumerateKeysAndObjectsUsingBlock:^(id extNameObj, id extConnectionObj, BOOL *stop) {
361
352
 
362
- [(YapDatabaseExtensionConnection *)extConnectionObj _flushMemoryWithLevel:level];
353
+ [(YapDatabaseExtensionConnection *)extConnectionObj _flushMemoryWithFlags:flags];
363
354
  }];
364
355
  }
365
356
 
@@ -381,11 +372,11 @@
381
372
  * YapDatabaseConnectionFlushMemoryLevelFull (3):
382
373
  * Full flush of all caches and removes all pre-compiled sqlite statements.
383
374
  **/
384
- - (void)flushMemoryWithLevel:(int)level
375
+ - (void)flushMemoryWithFlags:(YapDatabaseConnectionFlushMemoryFlags)flags
385
376
  {
386
377
  dispatch_block_t block = ^{
387
378
 
388
- [self _flushMemoryWithLevel:level];
379
+ [self _flushMemoryWithFlags:flags];
389
380
  };
390
381
 
391
382
  if (dispatch_get_specific(IsOnConnectionQueueKey))
@@ -397,7 +388,7 @@
397
388
  #if TARGET_OS_IPHONE
398
389
  - (void)didReceiveMemoryWarning:(NSNotification *)notification
399
390
  {
400
- [self flushMemoryWithLevel:[self autoFlushMemoryLevel]];
391
+ [self flushMemoryWithFlags:[self autoFlushMemoryFlags]];
401
392
  }
402
393
  #endif
403
394
 
@@ -408,10 +399,8 @@
408
399
  @synthesize database = database;
409
400
  @synthesize name = _name;
410
401
 
411
- //@synthesize connectionQueue = connectionQueue;
412
-
413
402
  #if TARGET_OS_IPHONE
414
- @synthesize autoFlushMemoryLevel;
403
+ @synthesize autoFlushMemoryFlags;
415
404
  #endif
416
405
 
417
406
  - (BOOL)objectCacheEnabled
@@ -446,6 +435,8 @@
446
435
  {
447
436
  objectCache = nil;
448
437
  }
438
+
439
+ [self updateKeyCacheLimit];
449
440
  };
450
441
 
451
442
  if (dispatch_get_specific(IsOnConnectionQueueKey))
@@ -480,11 +471,12 @@
480
471
 
481
472
  if (objectCache == nil)
482
473
  {
483
- return; // Limit changed, but objectCache is still disabled
474
+ // Limit changed, but objectCache is still disabled
484
475
  }
485
476
  else
486
477
  {
487
478
  objectCache.countLimit = objectCacheLimit;
479
+ [self updateKeyCacheLimit];
488
480
  }
489
481
  }
490
482
  };
@@ -527,6 +519,8 @@
527
519
  {
528
520
  metadataCache = nil;
529
521
  }
522
+
523
+ [self updateKeyCacheLimit];
530
524
  };
531
525
 
532
526
  if (dispatch_get_specific(IsOnConnectionQueueKey))
@@ -561,11 +555,12 @@
561
555
 
562
556
  if (metadataCache == nil)
563
557
  {
564
- return; // Limit changed but metadataCache still disabled
558
+ // Limit changed but metadataCache still disabled
565
559
  }
566
560
  else
567
561
  {
568
562
  metadataCache.countLimit = metadataCacheLimit;
563
+ [self updateKeyCacheLimit];
569
564
  }
570
565
  }
571
566
  };
@@ -664,6 +659,39 @@
664
659
  return result;
665
660
  }
666
661
 
662
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
663
+ #pragma mark Utilities
664
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
665
+
666
+ - (void)updateKeyCacheLimit
667
+ {
668
+ NSUInteger keyCacheLimit = MIN_KEY_CACHE_LIMIT;
669
+
670
+ if (keyCacheLimit != UNLIMITED_CACHE_LIMIT)
671
+ {
672
+ if (objectCache)
673
+ {
674
+ if (objectCacheLimit == UNLIMITED_CACHE_LIMIT)
675
+ keyCacheLimit = UNLIMITED_CACHE_LIMIT;
676
+ else
677
+ keyCacheLimit = MAX(keyCacheLimit, objectCacheLimit);
678
+ }
679
+ }
680
+
681
+ if (keyCacheLimit != UNLIMITED_CACHE_LIMIT)
682
+ {
683
+ if (metadataCache)
684
+ {
685
+ if (objectCacheLimit == UNLIMITED_CACHE_LIMIT)
686
+ keyCacheLimit = UNLIMITED_CACHE_LIMIT;
687
+ else
688
+ keyCacheLimit = MAX(keyCacheLimit, objectCacheLimit);
689
+ }
690
+ }
691
+
692
+ keyCache.countLimit = keyCacheLimit;
693
+ }
694
+
667
695
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
668
696
  #pragma mark Statements
669
697
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -678,7 +706,7 @@
678
706
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &beginTransactionStatement, NULL);
679
707
  if (status != SQLITE_OK)
680
708
  {
681
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
709
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
682
710
  }
683
711
  }
684
712
 
@@ -695,7 +723,7 @@
695
723
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &commitTransactionStatement, NULL);
696
724
  if (status != SQLITE_OK)
697
725
  {
698
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
726
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
699
727
  }
700
728
  }
701
729
 
@@ -712,7 +740,7 @@
712
740
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &rollbackTransactionStatement, NULL);
713
741
  if (status != SQLITE_OK)
714
742
  {
715
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
743
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
716
744
  }
717
745
  }
718
746
 
@@ -729,7 +757,7 @@
729
757
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &yapGetDataForKeyStatement, NULL);
730
758
  if (status != SQLITE_OK)
731
759
  {
732
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
760
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
733
761
  }
734
762
  }
735
763
 
@@ -746,13 +774,30 @@
746
774
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &yapSetDataForKeyStatement, NULL);
747
775
  if (status != SQLITE_OK)
748
776
  {
749
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
777
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
750
778
  }
751
779
  }
752
780
 
753
781
  return yapSetDataForKeyStatement;
754
782
  }
755
783
 
784
+ - (sqlite3_stmt *)yapRemoveForKeyStatement
785
+ {
786
+ if (yapRemoveForKeyStatement == NULL)
787
+ {
788
+ char *stmt = "DELETE FROM \"yap2\" WHERE \"extension\" = ? AND \"key\" = ?;";
789
+ int stmtLen = (int)strlen(stmt);
790
+
791
+ int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &yapRemoveForKeyStatement, NULL);
792
+ if (status != SQLITE_OK)
793
+ {
794
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
795
+ }
796
+ }
797
+
798
+ return yapRemoveForKeyStatement;
799
+ }
800
+
756
801
  - (sqlite3_stmt *)yapRemoveExtensionStatement
757
802
  {
758
803
  if (yapRemoveExtensionStatement == NULL)
@@ -763,7 +808,7 @@
763
808
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &yapRemoveExtensionStatement, NULL);
764
809
  if (status != SQLITE_OK)
765
810
  {
766
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
811
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
767
812
  }
768
813
  }
769
814
 
@@ -780,7 +825,7 @@
780
825
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &getCollectionCountStatement, NULL);
781
826
  if (status != SQLITE_OK)
782
827
  {
783
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
828
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
784
829
  }
785
830
  }
786
831
 
@@ -797,7 +842,7 @@
797
842
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &getKeyCountForCollectionStatement, NULL);
798
843
  if (status != SQLITE_OK)
799
844
  {
800
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
845
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
801
846
  }
802
847
  }
803
848
 
@@ -814,7 +859,7 @@
814
859
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &getKeyCountForAllStatement, NULL);
815
860
  if (status != SQLITE_OK)
816
861
  {
817
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
862
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
818
863
  }
819
864
  }
820
865
 
@@ -831,7 +876,7 @@
831
876
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &getCountForRowidStatement, NULL);
832
877
  if (status != SQLITE_OK)
833
878
  {
834
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
879
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
835
880
  }
836
881
  }
837
882
 
@@ -848,7 +893,7 @@
848
893
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &getRowidForKeyStatement, NULL);
849
894
  if (status != SQLITE_OK)
850
895
  {
851
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
896
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
852
897
  }
853
898
  }
854
899
 
@@ -865,75 +910,58 @@
865
910
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &getKeyForRowidStatement, NULL);
866
911
  if (status != SQLITE_OK)
867
912
  {
868
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
913
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
869
914
  }
870
915
  }
871
916
 
872
917
  return getKeyForRowidStatement;
873
918
  }
874
919
 
875
- - (sqlite3_stmt *)getKeyDataForRowidStatement
876
- {
877
- if (getKeyDataForRowidStatement == NULL)
878
- {
879
- char *stmt = "SELECT \"collection\", \"key\", \"data\" FROM \"database2\" WHERE \"rowid\" = ?;";
880
- int stmtLen = (int)strlen(stmt);
881
-
882
- int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &getKeyDataForRowidStatement, NULL);
883
- if (status != SQLITE_OK)
884
- {
885
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
886
- }
887
- }
888
-
889
- return getKeyDataForRowidStatement;
890
- }
891
-
892
- - (sqlite3_stmt *)getKeyMetadataForRowidStatement
920
+ - (sqlite3_stmt *)getDataForRowidStatement
893
921
  {
894
- if (getKeyMetadataForRowidStatement == NULL)
922
+ if (getDataForRowidStatement == NULL)
895
923
  {
896
- char *stmt = "SELECT \"collection\", \"key\", \"metadata\" FROM \"database2\" WHERE \"rowid\" = ?;";
924
+ char *stmt = "SELECT \"data\" FROM \"database2\" WHERE \"rowid\" = ?;";
897
925
  int stmtLen = (int)strlen(stmt);
898
926
 
899
- int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &getKeyMetadataForRowidStatement, NULL);
927
+ int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &getDataForRowidStatement, NULL);
900
928
  if (status != SQLITE_OK)
901
929
  {
902
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
930
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
903
931
  }
904
932
  }
905
933
 
906
- return getKeyMetadataForRowidStatement;
934
+ return getDataForRowidStatement;
907
935
  }
908
936
 
909
- - (sqlite3_stmt *)getDataForRowidStatement
937
+ - (sqlite3_stmt *)getMetadataForRowidStatement
910
938
  {
911
- if (getDataForRowidStatement == NULL)
939
+ if (getMetadataForRowidStatement == NULL)
912
940
  {
913
- char *stmt = "SELECT \"data\" FROM \"database2\" WHERE \"rowid\" = ?;";
941
+ char *stmt = "SELECT \"metadata\" FROM \"database2\" WHERE \"rowid\" = ?;";
914
942
  int stmtLen = (int)strlen(stmt);
915
943
 
916
- int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &getDataForRowidStatement, NULL);
944
+ int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &getMetadataForRowidStatement, NULL);
917
945
  if (status != SQLITE_OK)
918
946
  {
919
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
947
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
920
948
  }
921
949
  }
922
950
 
923
- return getDataForRowidStatement;
951
+ return getMetadataForRowidStatement;
924
952
  }
925
953
 
926
954
  - (sqlite3_stmt *)getAllForRowidStatement
927
955
  {
928
956
  if (getAllForRowidStatement == NULL)
929
957
  {
930
- char *stmt = "SELECT \"collection\", \"key\", \"data\", \"metadata\" FROM \"database2\" WHERE \"rowid\" = ?;";
958
+ char *stmt = "SELECT \"data\", \"metadata\" FROM \"database2\" WHERE \"rowid\" = ?;";
931
959
  int stmtLen = (int)strlen(stmt);
932
960
 
933
961
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &getAllForRowidStatement, NULL);
934
962
  if (status != SQLITE_OK)
935
963
  {
936
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
964
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
937
965
  }
938
966
  }
939
967
 
@@ -950,7 +978,7 @@
950
978
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &getDataForKeyStatement, NULL);
951
979
  if (status != SQLITE_OK)
952
980
  {
953
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
981
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
954
982
  }
955
983
  }
956
984
 
@@ -967,7 +995,7 @@
967
995
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &getMetadataForKeyStatement, NULL);
968
996
  if (status != SQLITE_OK)
969
997
  {
970
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
998
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
971
999
  }
972
1000
  }
973
1001
 
@@ -984,7 +1012,7 @@
984
1012
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &getAllForKeyStatement, NULL);
985
1013
  if (status != SQLITE_OK)
986
1014
  {
987
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
1015
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
988
1016
  }
989
1017
  }
990
1018
 
@@ -1002,7 +1030,7 @@
1002
1030
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &insertForRowidStatement, NULL);
1003
1031
  if (status != SQLITE_OK)
1004
1032
  {
1005
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
1033
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
1006
1034
  }
1007
1035
  }
1008
1036
 
@@ -1019,13 +1047,30 @@
1019
1047
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &updateAllForRowidStatement, NULL);
1020
1048
  if (status != SQLITE_OK)
1021
1049
  {
1022
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
1050
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
1023
1051
  }
1024
1052
  }
1025
1053
 
1026
1054
  return updateAllForRowidStatement;
1027
1055
  }
1028
1056
 
1057
+ - (sqlite3_stmt *)updateObjectForRowidStatement
1058
+ {
1059
+ if (updateObjectForRowidStatement == NULL)
1060
+ {
1061
+ char *stmt = "UPDATE \"database2\" SET \"data\" = ? WHERE \"rowid\" = ?;";
1062
+ int stmtLen = (int)strlen(stmt);
1063
+
1064
+ int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &updateObjectForRowidStatement, NULL);
1065
+ if (status != SQLITE_OK)
1066
+ {
1067
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
1068
+ }
1069
+ }
1070
+
1071
+ return updateObjectForRowidStatement;
1072
+ }
1073
+
1029
1074
  - (sqlite3_stmt *)updateMetadataForRowidStatement
1030
1075
  {
1031
1076
  if (updateMetadataForRowidStatement == NULL)
@@ -1036,7 +1081,7 @@
1036
1081
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &updateMetadataForRowidStatement, NULL);
1037
1082
  if (status != SQLITE_OK)
1038
1083
  {
1039
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
1084
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
1040
1085
  }
1041
1086
  }
1042
1087
 
@@ -1053,7 +1098,7 @@
1053
1098
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &removeForRowidStatement, NULL);
1054
1099
  if (status != SQLITE_OK)
1055
1100
  {
1056
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
1101
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
1057
1102
  }
1058
1103
  }
1059
1104
 
@@ -1070,7 +1115,7 @@
1070
1115
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &removeCollectionStatement, NULL);
1071
1116
  if (status != SQLITE_OK)
1072
1117
  {
1073
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
1118
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
1074
1119
  }
1075
1120
  }
1076
1121
 
@@ -1087,7 +1132,7 @@
1087
1132
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &removeAllStatement, NULL);
1088
1133
  if (status != SQLITE_OK)
1089
1134
  {
1090
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
1135
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
1091
1136
  }
1092
1137
  }
1093
1138
 
@@ -1104,7 +1149,7 @@
1104
1149
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &enumerateCollectionsStatement, NULL);
1105
1150
  if (status != SQLITE_OK)
1106
1151
  {
1107
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
1152
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
1108
1153
  }
1109
1154
  }
1110
1155
 
@@ -1121,7 +1166,7 @@
1121
1166
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &enumerateCollectionsForKeyStatement, NULL);
1122
1167
  if (status != SQLITE_OK)
1123
1168
  {
1124
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
1169
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
1125
1170
  }
1126
1171
  }
1127
1172
 
@@ -1138,7 +1183,7 @@
1138
1183
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &enumerateKeysInCollectionStatement, NULL);
1139
1184
  if (status != SQLITE_OK)
1140
1185
  {
1141
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
1186
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
1142
1187
  }
1143
1188
  }
1144
1189
 
@@ -1155,7 +1200,7 @@
1155
1200
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &enumerateKeysInAllCollectionsStatement, NULL);
1156
1201
  if (status != SQLITE_OK)
1157
1202
  {
1158
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
1203
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
1159
1204
  }
1160
1205
  }
1161
1206
 
@@ -1172,7 +1217,7 @@
1172
1217
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &enumerateKeysAndMetadataInCollectionStatement, NULL);
1173
1218
  if (status != SQLITE_OK)
1174
1219
  {
1175
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
1220
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
1176
1221
  }
1177
1222
  }
1178
1223
 
@@ -1190,7 +1235,7 @@
1190
1235
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &enumerateKeysAndMetadataInAllCollectionsStatement, NULL);
1191
1236
  if (status != SQLITE_OK)
1192
1237
  {
1193
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
1238
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
1194
1239
  }
1195
1240
  }
1196
1241
 
@@ -1207,7 +1252,7 @@
1207
1252
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &enumerateKeysAndObjectsInCollectionStatement, NULL);
1208
1253
  if (status != SQLITE_OK)
1209
1254
  {
1210
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
1255
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
1211
1256
  }
1212
1257
  }
1213
1258
 
@@ -1225,7 +1270,7 @@
1225
1270
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &enumerateKeysAndObjectsInAllCollectionsStatement, NULL);
1226
1271
  if (status != SQLITE_OK)
1227
1272
  {
1228
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
1273
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
1229
1274
  }
1230
1275
  }
1231
1276
 
@@ -1242,7 +1287,7 @@
1242
1287
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &enumerateRowsInCollectionStatement, NULL);
1243
1288
  if (status != SQLITE_OK)
1244
1289
  {
1245
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
1290
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
1246
1291
  }
1247
1292
  }
1248
1293
 
@@ -1261,7 +1306,7 @@
1261
1306
  int status = sqlite3_prepare_v2(db, stmt, stmtLen+1, &enumerateRowsInAllCollectionsStatement, NULL);
1262
1307
  if (status != SQLITE_OK)
1263
1308
  {
1264
- YDBLogError(@"Error creating '%@': %d %s", NSStringFromSelector(_cmd), status, sqlite3_errmsg(db));
1309
+ YDBLogError(@"Error creating '%@': %d %s", THIS_METHOD, status, sqlite3_errmsg(db));
1265
1310
  }
1266
1311
  }
1267
1312
 
@@ -1876,13 +1921,19 @@
1876
1921
 
1877
1922
  if (objectChanges == nil)
1878
1923
  objectChanges = [[NSMutableDictionary alloc] init];
1924
+
1879
1925
  if (metadataChanges == nil)
1880
1926
  metadataChanges = [[NSMutableDictionary alloc] init];
1927
+
1881
1928
  if (removedKeys == nil)
1882
1929
  removedKeys = [[NSMutableSet alloc] init];
1930
+
1883
1931
  if (removedCollections == nil)
1884
1932
  removedCollections = [[NSMutableSet alloc] init];
1885
1933
 
1934
+ if (removedRowids == nil)
1935
+ removedRowids = [[NSMutableSet alloc] init];
1936
+
1886
1937
  allKeysRemoved = NO;
1887
1938
 
1888
1939
  // Pre-Write-Transaction: Step 5 of 5
@@ -2010,35 +2061,7 @@
2010
2061
  {
2011
2062
  if ([registeredExtensions objectForKey:prevExtensionName] == nil)
2012
2063
  {
2013
- NSString *className = [transaction stringValueForKey:@"class" extension:prevExtensionName];
2014
- Class class = NSClassFromString(className);
2015
-
2016
- if (className == nil)
2017
- {
2018
- YDBLogWarn(@"Unable to auto-unregister extension(%@). Doesn't appear to be registered.",
2019
- prevExtensionName);
2020
- }
2021
- else if (class == NULL)
2022
- {
2023
- YDBLogError(@"Unable to auto-unregister extension(%@) with unknown class(%@)",
2024
- prevExtensionName, className);
2025
- }
2026
- if (![class isSubclassOfClass:[YapDatabaseExtension class]])
2027
- {
2028
- YDBLogError(@"Unable to auto-unregister extension(%@) with improper class(%@)",
2029
- prevExtensionName, className);
2030
- }
2031
- else
2032
- {
2033
- YDBLogInfo(@"Auto-unregistering extension(%@) with class(%@)",
2034
- prevExtensionName, className);
2035
-
2036
- // Drop tables
2037
- [class dropTablesForRegisteredName:prevExtensionName withTransaction:transaction];
2038
-
2039
- // Drop preferences (rows in yap2 table)
2040
- [transaction removeAllValuesForExtension:prevExtensionName];
2041
- }
2064
+ [self _unregisterExtension:prevExtensionName withTransaction:transaction];
2042
2065
  }
2043
2066
  }
2044
2067
 
@@ -2224,13 +2247,19 @@
2224
2247
 
2225
2248
  if ([objectChanges count] > 0)
2226
2249
  objectChanges = nil;
2250
+
2227
2251
  if ([metadataChanges count] > 0)
2228
2252
  metadataChanges = nil;
2253
+
2229
2254
  if ([removedKeys count] > 0)
2230
2255
  removedKeys = nil;
2256
+
2231
2257
  if ([removedCollections count] > 0)
2232
2258
  removedCollections = nil;
2233
2259
 
2260
+ if ([removedRowids count] > 0)
2261
+ removedRowids = nil;
2262
+
2234
2263
  // Post-Write-Transaction: Step 11 of 11
2235
2264
  //
2236
2265
  // Drop IsOnConnectionQueueKey flag from writeQueue since we're exiting writeQueue.
@@ -2386,12 +2415,18 @@
2386
2415
 
2387
2416
  if ([objectChanges count] > 0)
2388
2417
  objectChanges = nil;
2418
+
2389
2419
  if ([metadataChanges count] > 0)
2390
2420
  metadataChanges = nil;
2421
+
2391
2422
  if ([removedKeys count] > 0)
2392
2423
  removedKeys = nil;
2424
+
2393
2425
  if ([removedCollections count] > 0)
2394
2426
  removedCollections = nil;
2427
+
2428
+ if ([removedRowids count] > 0)
2429
+ removedRowids = nil;
2395
2430
  }
2396
2431
 
2397
2432
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -2541,11 +2576,13 @@
2541
2576
  YapDatabaseRegisteredExtensionsKey,
2542
2577
  YapDatabaseRegisteredTablesKey,
2543
2578
  YapDatabaseExtensionsOrderKey,
2579
+ YapDatabaseExtensionDependenciesKey,
2544
2580
  YapDatabaseNotificationKey,
2545
2581
  YapDatabaseObjectChangesKey,
2546
2582
  YapDatabaseMetadataChangesKey,
2547
2583
  YapDatabaseRemovedKeysKey,
2548
2584
  YapDatabaseRemovedCollectionsKey,
2585
+ YapDatabaseRemovedRowidsKey,
2549
2586
  YapDatabaseAllKeysRemovedKey ];
2550
2587
  }
2551
2588
 
@@ -2644,6 +2681,7 @@
2644
2681
 
2645
2682
  [internalChangeset setObject:registeredExtensions forKey:YapDatabaseRegisteredExtensionsKey];
2646
2683
  [internalChangeset setObject:extensionsOrder forKey:YapDatabaseExtensionsOrderKey];
2684
+ [internalChangeset setObject:extensionDependencies forKey:YapDatabaseExtensionDependenciesKey];
2647
2685
  }
2648
2686
 
2649
2687
  if (registeredTablesChanged)
@@ -2662,7 +2700,8 @@
2662
2700
  if ([objectChanges count] > 0 ||
2663
2701
  [metadataChanges count] > 0 ||
2664
2702
  [removedKeys count] > 0 ||
2665
- [removedCollections count] > 0 || allKeysRemoved)
2703
+ [removedCollections count] > 0 ||
2704
+ [removedRowids count] > 0 || allKeysRemoved)
2666
2705
  {
2667
2706
  if (internalChangeset == nil)
2668
2707
  internalChangeset = [NSMutableDictionary dictionaryWithSharedKeySet:sharedKeySetForInternalChangeset];
@@ -2703,6 +2742,11 @@
2703
2742
  forKey:YapDatabaseRemovedCollectionsKey];
2704
2743
  }
2705
2744
 
2745
+ if ([removedRowids count] > 0)
2746
+ {
2747
+ [internalChangeset setObject:removedRowids forKey:YapDatabaseRemovedRowidsKey];
2748
+ }
2749
+
2706
2750
  if (allKeysRemoved)
2707
2751
  {
2708
2752
  [internalChangeset setObject:@(YES) forKey:YapDatabaseAllKeysRemovedKey];
@@ -2731,6 +2775,7 @@
2731
2775
 
2732
2776
  registeredExtensions = changeset_registeredExtensions;
2733
2777
  extensionsOrder = [changeset objectForKey:YapDatabaseExtensionsOrderKey];
2778
+ extensionDependencies = [changeset objectForKey:YapDatabaseExtensionDependenciesKey];
2734
2779
 
2735
2780
  // Remove any extensions that have been dropped
2736
2781
 
@@ -2784,8 +2829,9 @@
2784
2829
  NSDictionary *changeset_objectChanges = [changeset objectForKey:YapDatabaseObjectChangesKey];
2785
2830
  NSDictionary *changeset_metadataChanges = [changeset objectForKey:YapDatabaseMetadataChangesKey];
2786
2831
 
2787
- NSSet *changeset_removedKeys = [changeset objectForKey:YapDatabaseRemovedKeysKey];
2788
- NSSet *changeset_removedCollections = [changeset objectForKey:YapDatabaseRemovedCollectionsKey];
2832
+ NSSet *changeset_removedRowids = [changeset objectForKey:YapDatabaseRemovedRowidsKey];
2833
+ NSSet *changeset_removedKeys = [changeset objectForKey:YapDatabaseRemovedKeysKey];
2834
+ NSSet *changeset_removedCollections = [changeset objectForKey:YapDatabaseRemovedCollectionsKey];
2789
2835
 
2790
2836
  BOOL changeset_allKeysRemoved = [[changeset objectForKey:YapDatabaseAllKeysRemovedKey] boolValue];
2791
2837
 
@@ -2794,6 +2840,45 @@
2794
2840
  BOOL hasRemovedKeys = [changeset_removedKeys count] > 0;
2795
2841
  BOOL hasRemovedCollections = [changeset_removedCollections count] > 0;
2796
2842
 
2843
+ // Update keyCache
2844
+
2845
+ if (changeset_allKeysRemoved)
2846
+ {
2847
+ // Shortcut: Everything was removed from the database
2848
+
2849
+ [keyCache removeAllObjects];
2850
+ }
2851
+ else
2852
+ {
2853
+ if (hasRemovedCollections)
2854
+ {
2855
+ __block NSMutableArray *toRemove = nil;
2856
+ [keyCache enumerateKeysAndObjectsWithBlock:^(id key, id obj, BOOL *stop) {
2857
+
2858
+ __unsafe_unretained NSNumber *rowidNumber = (NSNumber *)key;
2859
+ __unsafe_unretained YapCollectionKey *collectionKey = (YapCollectionKey *)obj;
2860
+
2861
+ if ([changeset_removedCollections containsObject:collectionKey.collection])
2862
+ {
2863
+ if (toRemove == nil)
2864
+ toRemove = [NSMutableArray array];
2865
+
2866
+ [toRemove addObject:rowidNumber];
2867
+ }
2868
+ }];
2869
+
2870
+ [keyCache removeObjectsForKeys:toRemove];
2871
+ }
2872
+
2873
+ if (changeset_removedRowids)
2874
+ {
2875
+ [changeset_removedRowids enumerateObjectsUsingBlock:^(id obj, BOOL *stop) {
2876
+
2877
+ [keyCache removeObjectForKey:obj];
2878
+ }];
2879
+ }
2880
+ }
2881
+
2797
2882
  // Update objectCache
2798
2883
 
2799
2884
  if (changeset_allKeysRemoved && !hasObjectChanges)
@@ -3203,6 +3288,7 @@
3203
3288
  includingObjectChanges:(BOOL)includeObjectChanges
3204
3289
  metadataChanges:(BOOL)includeMetadataChanges
3205
3290
  {
3291
+ if (key == nil) return NO;
3206
3292
  if (collection == nil)
3207
3293
  collection = @"";
3208
3294
 
@@ -3490,6 +3576,10 @@
3490
3576
  YapDatabaseReadWriteTransaction *transaction = [self newReadWriteTransaction];
3491
3577
  [self preReadWriteTransaction:transaction];
3492
3578
 
3579
+ // Set the registeredName now.
3580
+ // The extension will need this in order to perform the registration tasks such as creating tables, etc.
3581
+ extension.registeredName = extensionName;
3582
+
3493
3583
  YapDatabaseExtensionConnection *extensionConnection;
3494
3584
  YapDatabaseExtensionTransaction *extensionTransaction;
3495
3585
 
@@ -3514,6 +3604,9 @@
3514
3604
  }
3515
3605
  else
3516
3606
  {
3607
+ // Registration failed.
3608
+
3609
+ extension.registeredName = nil;
3517
3610
  [transaction rollback];
3518
3611
  }
3519
3612
 
@@ -3533,40 +3626,103 @@
3533
3626
  YapDatabaseReadWriteTransaction *transaction = [self newReadWriteTransaction];
3534
3627
  [self preReadWriteTransaction:transaction];
3535
3628
 
3536
- NSString *className = [transaction stringValueForKey:@"class" extension:extensionName];
3537
- Class class = NSClassFromString(className);
3629
+ // Unregister the given extension
3538
3630
 
3539
- if (className == nil)
3540
- {
3541
- YDBLogWarn(@"Unable to unregister extension(%@). Doesn't appear to be registered.", extensionName);
3542
- }
3543
- else if (class == NULL)
3544
- {
3545
- YDBLogError(@"Unable to unregister extension(%@) with unknown class(%@)", extensionName, className);
3546
- }
3547
- if (![class isSubclassOfClass:[YapDatabaseExtension class]])
3548
- {
3549
- YDBLogError(@"Unable to unregister extension(%@) with improper class(%@)", extensionName, className);
3550
- }
3551
- else
3631
+ YapDatabaseExtension *extension = [registeredExtensions objectForKey:extensionName];
3632
+
3633
+ [self _unregisterExtension:extensionName withTransaction:transaction];
3634
+ extension.registeredName = nil;
3635
+
3636
+ // Automatically unregister any extensions that were dependent upon this one.
3637
+
3638
+ NSMutableArray *extensionNameStack = [NSMutableArray arrayWithCapacity:1];
3639
+ [extensionNameStack addObject:extensionName];
3640
+
3641
+ do
3552
3642
  {
3553
- // Drop tables
3554
- [class dropTablesForRegisteredName:extensionName withTransaction:transaction];
3643
+ NSString *currentExtensionName = [extensionNameStack lastObject];
3555
3644
 
3556
- // Drop preferences (rows in yap2 table)
3557
- [transaction removeAllValuesForExtension:extensionName];
3645
+ __block NSString *dependentExtName = nil;
3646
+ [extensionDependencies enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop){
3647
+
3648
+ // __unsafe_unretained NSString *extName = (NSString *)key;
3649
+ __unsafe_unretained NSSet *extDependencies = (NSSet *)obj;
3650
+
3651
+ if ([extDependencies containsObject:currentExtensionName])
3652
+ {
3653
+ dependentExtName = (NSString *)key;
3654
+ *stop = YES;
3655
+ }
3656
+ }];
3558
3657
 
3559
- [self didUnregisterExtension:extensionName];
3658
+ if (dependentExtName)
3659
+ {
3660
+ // We found an extension that was dependent upon the one we just unregistered.
3661
+ // So we need to unregister it too.
3662
+
3663
+ YapDatabaseExtension *dependentExt = [registeredExtensions objectForKey:dependentExtName];
3664
+
3665
+ [self _unregisterExtension:dependentExtName withTransaction:transaction];
3666
+ dependentExt.registeredName = nil;
3667
+
3668
+ // And now we need to check and see if there were any extensions dependent upon this new one.
3669
+ // So we add it to the top of the stack, and continue our search.
3670
+
3671
+ [extensionNameStack addObject:dependentExtName];
3672
+ }
3673
+ else
3674
+ {
3675
+ [extensionNameStack removeLastObject];
3676
+ }
3560
3677
 
3561
- [self removeRegisteredExtensionConnection:extensionName];
3562
- [transaction removeRegisteredExtensionTransaction:extensionName];
3563
- }
3678
+ } while ([extensionNameStack count] > 0);
3679
+
3564
3680
 
3681
+ // Complete the transaction
3565
3682
  [self postReadWriteTransaction:transaction];
3683
+
3684
+ // And reset the registeredExtensionsChanged ivar.
3685
+ // The above method already processed it, and included the appropriate information in the changeset.
3566
3686
  registeredExtensionsChanged = NO;
3567
3687
  }});
3568
3688
  }
3569
3689
 
3690
+ - (void)_unregisterExtension:(NSString *)extensionName withTransaction:(YapDatabaseReadWriteTransaction *)transaction
3691
+ {
3692
+ NSString *className = [transaction stringValueForKey:@"class" extension:extensionName];
3693
+ Class class = NSClassFromString(className);
3694
+
3695
+ if (className == nil)
3696
+ {
3697
+ YDBLogWarn(@"Unable to unregister extension(%@). Doesn't appear to be registered.", extensionName);
3698
+ }
3699
+ else if (class == NULL)
3700
+ {
3701
+ YDBLogError(@"Unable to unregister extension(%@) with unknown class(%@)", extensionName, className);
3702
+ }
3703
+ if (![class isSubclassOfClass:[YapDatabaseExtension class]])
3704
+ {
3705
+ YDBLogError(@"Unable to unregister extension(%@) with improper class(%@)", extensionName, className);
3706
+ }
3707
+ else
3708
+ {
3709
+ // Drop tables
3710
+ [class dropTablesForRegisteredName:extensionName withTransaction:transaction];
3711
+
3712
+ // Drop preferences (rows in yap2 table)
3713
+ [transaction removeAllValuesForExtension:extensionName];
3714
+
3715
+ // Remove from registeredExtensions, extensionsOrder & extensionDependencies (if needed)
3716
+ [self didUnregisterExtension:extensionName];
3717
+
3718
+ // Remove YapDatabaseExtensionConnection subclass instance (if needed)
3719
+ [self removeRegisteredExtensionConnection:extensionName];
3720
+
3721
+ // Remove YapDatabaseExtensionTransaction subclass instance (if needed)
3722
+ [transaction removeRegisteredExtensionTransaction:extensionName];
3723
+ }
3724
+ }
3725
+
3570
3726
  - (void)willRegisterExtension:(YapDatabaseExtension *)extension
3571
3727
  withTransaction:(YapDatabaseReadWriteTransaction *)transaction
3572
3728
  needsClassValue:(BOOL *)needsClassValuePtr
@@ -3657,13 +3813,19 @@
3657
3813
  NSMutableDictionary *newRegisteredExtensions = [registeredExtensions mutableCopy];
3658
3814
  [newRegisteredExtensions setObject:extension forKey:extensionName];
3659
3815
 
3660
- NSMutableArray *newExtensionsOrder = [extensionsOrder mutableCopy];
3661
- [newExtensionsOrder addObject:extensionName];
3662
-
3663
3816
  registeredExtensions = [newRegisteredExtensions copy];
3664
- extensionsOrder = [newExtensionsOrder copy];
3665
- extensionsReady = NO;
3817
+ extensionsOrder = [extensionsOrder arrayByAddingObject:extensionName];
3818
+
3819
+ NSSet *dependencies = [extension dependencies];
3820
+ if (dependencies == nil)
3821
+ dependencies = [NSSet set];
3822
+
3823
+ NSMutableDictionary *newExtensionDependencies = [extensionDependencies mutableCopy];
3824
+ [newExtensionDependencies setObject:dependencies forKey:extensionName];
3825
+
3826
+ extensionDependencies = [newExtensionDependencies copy];
3666
3827
 
3828
+ extensionsReady = NO;
3667
3829
  sharedKeySetForExtensions = [NSDictionary sharedKeySetForKeys:[registeredExtensions allKeys]];
3668
3830
 
3669
3831
  // Set the registeredExtensionsChanged flag.
@@ -3684,8 +3846,18 @@
3684
3846
  [newRegisteredExtensions removeObjectForKey:extensionName];
3685
3847
 
3686
3848
  registeredExtensions = [newRegisteredExtensions copy];
3687
- extensionsReady = NO;
3688
3849
 
3850
+ NSMutableArray *newExtensionsOrder = [extensionsOrder mutableCopy];
3851
+ [newExtensionsOrder removeObject:extensionName];
3852
+
3853
+ extensionsOrder = [newExtensionsOrder copy];
3854
+
3855
+ NSMutableDictionary *newExtensionDependencies = [extensionDependencies mutableCopy];
3856
+ [newExtensionDependencies removeObjectForKey:extensionName];
3857
+
3858
+ extensionDependencies = [newExtensionDependencies copy];
3859
+
3860
+ extensionsReady = NO;
3689
3861
  sharedKeySetForExtensions = [NSDictionary sharedKeySetForKeys:[registeredExtensions allKeys]];
3690
3862
 
3691
3863
  // Set the registeredExtensionsChanged flag.