motion-yapper 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.travis.yml +6 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +63 -0
- data/README.md +16 -0
- data/Rakefile +20 -0
- data/app/app_delegate.rb +5 -0
- data/lib/yapper.rb +30 -0
- data/lib/yapper/attachment.rb +48 -0
- data/lib/yapper/bson.rb +20 -0
- data/lib/yapper/config.rb +18 -0
- data/lib/yapper/db.rb +151 -0
- data/lib/yapper/document.rb +54 -0
- data/lib/yapper/document/attachment.rb +26 -0
- data/lib/yapper/document/callbacks.rb +86 -0
- data/lib/yapper/document/persistance.rb +171 -0
- data/lib/yapper/document/relation.rb +84 -0
- data/lib/yapper/document/selection.rb +100 -0
- data/lib/yapper/extensions.rb +80 -0
- data/lib/yapper/log.rb +5 -0
- data/lib/yapper/sync.rb +134 -0
- data/lib/yapper/sync/data.rb +12 -0
- data/lib/yapper/sync/event.rb +194 -0
- data/lib/yapper/sync/queue.rb +164 -0
- data/lib/yapper/timestamps.rb +16 -0
- data/lib/yapper/version.rb +3 -0
- data/lib/yapper/yapper.rb +2 -0
- data/spec/helpers/time_helper.rb +3 -0
- data/spec/integration/all_spec.rb +40 -0
- data/spec/integration/callback_spec.rb +87 -0
- data/spec/integration/db_spec.rb +40 -0
- data/spec/integration/find_spec.rb +51 -0
- data/spec/integration/persistance_spec.rb +118 -0
- data/spec/integration/relation_spec.rb +174 -0
- data/spec/integration/sync_spec.rb +42 -0
- data/spec/integration/timestamps_spec.rb +34 -0
- data/spec/integration/types_spec.rb +23 -0
- data/spec/integration/when_spec.rb +29 -0
- data/spec/integration/where_spec.rb +132 -0
- data/vendor/Podfile.lock +24 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.h +641 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.m +1396 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h +133 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m +327 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.h +113 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.m +321 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.h +71 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.m +150 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.m +157 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFNetworking.h +43 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.h +68 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.m +143 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h +370 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m +848 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.h +89 -0
- data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.m +167 -0
- data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.h +78 -0
- data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.m +191 -0
- data/vendor/Pods/AFNetworking/LICENSE +19 -0
- data/vendor/Pods/AFNetworking/README.md +208 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPClient.h +641 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPRequestOperation.h +133 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFImageRequestOperation.h +113 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFJSONRequestOperation.h +71 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworking.h +43 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFPropertyListRequestOperation.h +68 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFURLConnectionOperation.h +370 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/AFXMLRequestOperation.h +89 -0
- data/vendor/Pods/BuildHeaders/AFNetworking/UIImageView+AFNetworking.h +78 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/ContextFilterLogFormatter.h +65 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDASLLogger.h +41 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDAbstractDatabaseLogger.h +102 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDFileLogger.h +334 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog.h +601 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDTTYLogger.h +167 -0
- data/vendor/Pods/BuildHeaders/CocoaLumberjack/DispatchQueueLogFormatter.h +116 -0
- data/vendor/Pods/BuildHeaders/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
- data/vendor/Pods/BuildHeaders/Reachability/Reachability.h +109 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapCache.h +90 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapCollectionKey.h +20 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabase.h +547 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnection.h +447 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnectionState.h +29 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseDefaults.h +37 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtension.h +15 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionConnection.h +11 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionPrivate.h +440 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionTransaction.h +11 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredView.h +108 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewConnection.h +12 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewPrivate.h +19 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTransaction.h +39 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearch.h +89 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchConnection.h +32 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchPrivate.h +69 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchTransaction.h +68 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseLogging.h +158 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseManager.h +17 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabasePrivate.h +424 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseQuery.h +42 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndex.h +100 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexConnection.h +33 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +73 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexSetup.h +33 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +58 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseStatement.h +13 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseString.h +121 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseTransaction.h +541 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseView.h +186 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChange.h +272 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChangePrivate.h +94 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewConnection.h +115 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappings.h +825 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappingsPrivate.h +72 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewOptions.h +56 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPage.h +36 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPageMetadata.h +27 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPrivate.h +153 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptions.h +330 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +17 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTransaction.h +447 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapMemoryTable.h +74 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapNull.h +17 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapSet.h +41 -0
- data/vendor/Pods/BuildHeaders/YapDatabase/YapTouch.h +15 -0
- data/vendor/Pods/CocoaLumberjack/LICENSE.txt +18 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.h +41 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m +99 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.h +102 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m +727 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.h +334 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.m +1353 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.h +601 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.m +1083 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.h +167 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.m +1479 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.h +65 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.m +191 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.h +116 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.m +251 -0
- data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/README.txt +7 -0
- data/vendor/Pods/CocoaLumberjack/README.markdown +37 -0
- data/vendor/Pods/Headers/AFNetworking/AFHTTPClient.h +641 -0
- data/vendor/Pods/Headers/AFNetworking/AFHTTPRequestOperation.h +133 -0
- data/vendor/Pods/Headers/AFNetworking/AFImageRequestOperation.h +113 -0
- data/vendor/Pods/Headers/AFNetworking/AFJSONRequestOperation.h +71 -0
- data/vendor/Pods/Headers/AFNetworking/AFNetworkActivityIndicatorManager.h +75 -0
- data/vendor/Pods/Headers/AFNetworking/AFNetworking.h +43 -0
- data/vendor/Pods/Headers/AFNetworking/AFPropertyListRequestOperation.h +68 -0
- data/vendor/Pods/Headers/AFNetworking/AFURLConnectionOperation.h +370 -0
- data/vendor/Pods/Headers/AFNetworking/AFXMLRequestOperation.h +89 -0
- data/vendor/Pods/Headers/AFNetworking/UIImageView+AFNetworking.h +78 -0
- data/vendor/Pods/Headers/CocoaLumberjack/ContextFilterLogFormatter.h +65 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDASLLogger.h +41 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDAbstractDatabaseLogger.h +102 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDFileLogger.h +334 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDLog.h +601 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DDTTYLogger.h +167 -0
- data/vendor/Pods/Headers/CocoaLumberjack/DispatchQueueLogFormatter.h +116 -0
- data/vendor/Pods/Headers/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
- data/vendor/Pods/Headers/Reachability/Reachability.h +109 -0
- data/vendor/Pods/Headers/YapDatabase/YapCache.h +90 -0
- data/vendor/Pods/Headers/YapDatabase/YapCollectionKey.h +20 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabase.h +547 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnection.h +447 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnectionState.h +29 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseDefaults.h +37 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtension.h +15 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionConnection.h +11 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionPrivate.h +440 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionTransaction.h +11 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredView.h +108 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewConnection.h +12 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewPrivate.h +19 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTransaction.h +39 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearch.h +89 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchConnection.h +32 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchPrivate.h +69 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchTransaction.h +68 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseLogging.h +158 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseManager.h +17 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabasePrivate.h +424 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseQuery.h +42 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndex.h +100 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexConnection.h +33 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +73 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexSetup.h +33 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexTransaction.h +58 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseStatement.h +13 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseString.h +121 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseTransaction.h +541 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseView.h +186 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChange.h +272 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChangePrivate.h +94 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewConnection.h +115 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappings.h +825 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappingsPrivate.h +72 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewOptions.h +56 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPage.h +36 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPageMetadata.h +27 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPrivate.h +153 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptions.h +330 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +17 -0
- data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTransaction.h +447 -0
- data/vendor/Pods/Headers/YapDatabase/YapMemoryTable.h +74 -0
- data/vendor/Pods/Headers/YapDatabase/YapNull.h +17 -0
- data/vendor/Pods/Headers/YapDatabase/YapSet.h +41 -0
- data/vendor/Pods/Headers/YapDatabase/YapTouch.h +15 -0
- data/vendor/Pods/Headers/____Pods-AFNetworking-prefix.h +17 -0
- data/vendor/Pods/Headers/____Pods-CocoaLumberjack-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-NSData+MD5Digest-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-Reachability-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-YapDatabase-prefix.h +5 -0
- data/vendor/Pods/Headers/____Pods-environment.h +38 -0
- data/vendor/Pods/Manifest.lock +24 -0
- data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.h +18 -0
- data/vendor/Pods/NSData+MD5Digest/NSData+MD5Digest/NSData+MD5Digest.m +39 -0
- data/vendor/Pods/NSData+MD5Digest/README.md +11 -0
- data/vendor/Pods/Pods-AFNetworking-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-AFNetworking-dummy.m +5 -0
- data/vendor/Pods/Pods-AFNetworking-prefix.pch +17 -0
- data/vendor/Pods/Pods-AFNetworking.xcconfig +1 -0
- data/vendor/Pods/Pods-Acknowledgements.markdown +96 -0
- data/vendor/Pods/Pods-Acknowledgements.plist +142 -0
- data/vendor/Pods/Pods-CocoaLumberjack-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-CocoaLumberjack-dummy.m +5 -0
- data/vendor/Pods/Pods-CocoaLumberjack-prefix.pch +5 -0
- data/vendor/Pods/Pods-CocoaLumberjack.xcconfig +0 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-dummy.m +5 -0
- data/vendor/Pods/Pods-NSData+MD5Digest-prefix.pch +5 -0
- data/vendor/Pods/Pods-NSData+MD5Digest.xcconfig +0 -0
- data/vendor/Pods/Pods-Reachability-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-Reachability-dummy.m +5 -0
- data/vendor/Pods/Pods-Reachability-prefix.pch +5 -0
- data/vendor/Pods/Pods-Reachability.xcconfig +1 -0
- data/vendor/Pods/Pods-YapDatabase-Private.xcconfig +5 -0
- data/vendor/Pods/Pods-YapDatabase-dummy.m +5 -0
- data/vendor/Pods/Pods-YapDatabase-prefix.pch +5 -0
- data/vendor/Pods/Pods-YapDatabase.xcconfig +1 -0
- data/vendor/Pods/Pods-dummy.m +5 -0
- data/vendor/Pods/Pods-environment.h +38 -0
- data/vendor/Pods/Pods-resources.sh +68 -0
- data/vendor/Pods/Pods.bridgesupport +5096 -0
- data/vendor/Pods/Pods.xcconfig +5 -0
- data/vendor/Pods/Pods.xcodeproj/project.pbxproj +5536 -0
- data/vendor/Pods/Reachability/LICENCE.txt +24 -0
- data/vendor/Pods/Reachability/README.md +65 -0
- data/vendor/Pods/Reachability/Reachability.h +109 -0
- data/vendor/Pods/Reachability/Reachability.m +527 -0
- data/vendor/Pods/YapDatabase/LICENSE.txt +18 -0
- data/vendor/Pods/YapDatabase/README.md +30 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/Internal/YapDatabaseFilteredViewPrivate.h +19 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.h +108 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.m +175 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.h +12 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewConnection.m +41 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.h +39 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.m +966 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/Internal/YapDatabaseFullTextSearchPrivate.h +69 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.h +89 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearch.m +146 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.h +32 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.m +298 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.h +79 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchSnippetOptions.m +95 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.h +68 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.m +1352 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/Internal/YapDatabaseExtensionPrivate.h +440 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.h +15 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.m +58 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.h +11 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.m +46 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.h +11 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.m +180 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexPrivate.h +73 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.h +100 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.m +149 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.h +33 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.m +330 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.h +33 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.m +184 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.h +58 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.m +1166 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewChangePrivate.h +94 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewMappingsPrivate.h +72 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.h +36 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPage.mm +296 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.h +27 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPageMetadata.m +28 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPrivate.h +153 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewRangeOptionsPrivate.h +17 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.h +272 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.m +2494 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.h +825 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.m +1567 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.h +330 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewRangeOptions.m +141 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.h +186 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.m +191 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.h +115 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.m +897 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.h +56 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.m +27 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.h +447 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.m +4505 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.h +90 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.m +453 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.h +29 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseConnectionState.m +48 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.h +37 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.m +83 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.h +158 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseLogging.m +73 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.h +17 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseManager.m +56 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabasePrivate.h +424 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.h +13 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseStatement.m +26 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseString.h +121 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.h +74 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapMemoryTable.m +603 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.h +17 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.m +31 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.h +15 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapTouch.m +31 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.h +20 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.m +194 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.h +42 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapDatabaseQuery.m +96 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.h +41 -0
- data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapSet.m +82 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.h +547 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.m +2022 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.h +447 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.m +3874 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.h +541 -0
- data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.m +5282 -0
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.bridgesupport +16 -0
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.h +13 -0
- data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.m +20 -0
- data/yapper.gemspec +24 -0
- metadata +458 -0
@@ -0,0 +1,90 @@
|
|
1
|
+
#import <Foundation/Foundation.h>
|
2
|
+
|
3
|
+
#define YAP_CACHE_STATISTICS 0
|
4
|
+
|
5
|
+
/**
|
6
|
+
* YapCache implements a simple strict cache.
|
7
|
+
*
|
8
|
+
* It is very similar to NSCache and shares a similar API.
|
9
|
+
* However, YapCache implements a strict countLimit and monitors usage so eviction is properly ordered.
|
10
|
+
*
|
11
|
+
* For example:
|
12
|
+
* If you set a countLimit of 4, then when you add the 5th item to the cache, another item is automatically evicted.
|
13
|
+
* It doesn't happen at a later time as with NSCache. It happens atomically during the addition of the 5th item.
|
14
|
+
|
15
|
+
* Which item gets evicted? That depends entirely on usage.
|
16
|
+
* YapCache maintains a doubly linked-list of keys ordered by access.
|
17
|
+
* The most recently accessed key is at the front of the linked-list,
|
18
|
+
* and the least recently accessed key is at the back.
|
19
|
+
* So it's very quick and efficient to evict items based on recent usage.
|
20
|
+
*
|
21
|
+
* YapCache is NOT thread-safe.
|
22
|
+
* It is designed to be used by the various YapDatabase classes, which inherently serialize access to the cache.
|
23
|
+
**/
|
24
|
+
|
25
|
+
@interface YapCache : NSObject
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Initializes a cache.
|
29
|
+
*
|
30
|
+
* Since the countLimit is a common configuration, it may optionally be passed during initialization.
|
31
|
+
* This is also used as a hint internally when initializing components (i.e. [NSMutableDictionary initWithCapacity:]).
|
32
|
+
**/
|
33
|
+
- (id)initWithKeyClass:(Class)keyClass;
|
34
|
+
- (id)initWithKeyClass:(Class)keyClass countLimit:(NSUInteger)countLimit;
|
35
|
+
|
36
|
+
/**
|
37
|
+
* The countLimit specifies the maximum number of items to keep in the cache.
|
38
|
+
* This limit is strictly enforced.
|
39
|
+
*
|
40
|
+
* The default countLimit is 40.
|
41
|
+
*
|
42
|
+
* You may optionally disable the countLimit by setting it to zero.
|
43
|
+
*
|
44
|
+
* You may change the countLimit at any time.
|
45
|
+
* Changes to the countLimit take immediate effect on the cache (before the set method returns).
|
46
|
+
* Thus, if needed, you can temporarily increase the cache size for certain operations.
|
47
|
+
**/
|
48
|
+
@property (nonatomic, assign, readwrite) NSUInteger countLimit;
|
49
|
+
|
50
|
+
//
|
51
|
+
// The normal cache stuff...
|
52
|
+
//
|
53
|
+
|
54
|
+
- (void)setObject:(id)object forKey:(id)key;
|
55
|
+
|
56
|
+
- (id)objectForKey:(id)key;
|
57
|
+
- (BOOL)containsKey:(id)key;
|
58
|
+
|
59
|
+
- (NSUInteger)count;
|
60
|
+
|
61
|
+
- (void)removeAllObjects;
|
62
|
+
- (void)removeObjectForKey:(id)key;
|
63
|
+
- (void)removeObjectsForKeys:(NSArray *)keys;
|
64
|
+
|
65
|
+
- (void)enumerateKeysWithBlock:(void (^)(id key, BOOL *stop))block;
|
66
|
+
|
67
|
+
//
|
68
|
+
// Some debugging stuff that gets compiled out
|
69
|
+
//
|
70
|
+
|
71
|
+
#if YAP_CACHE_STATISTICS
|
72
|
+
|
73
|
+
/**
|
74
|
+
* When querying the cache for an object via objectForKey,
|
75
|
+
* the hitCount is incremented if the object is in the cache,
|
76
|
+
* and the missCount is incremented if the object is not in the cache.
|
77
|
+
**/
|
78
|
+
@property (nonatomic, readonly) NSUInteger hitCount;
|
79
|
+
@property (nonatomic, readonly) NSUInteger missCount;
|
80
|
+
|
81
|
+
/**
|
82
|
+
* When adding objects to the cache via setObject:forKey:,
|
83
|
+
* the evictionCount is incremented if the cache is full,
|
84
|
+
* and the added object causes another object (the least recently used object) to be evicted.
|
85
|
+
**/
|
86
|
+
@property (nonatomic, readonly) NSUInteger evictionCount;
|
87
|
+
|
88
|
+
#endif
|
89
|
+
|
90
|
+
@end
|
@@ -0,0 +1,453 @@
|
|
1
|
+
#import "YapCache.h"
|
2
|
+
#import "YapDatabaseLogging.h"
|
3
|
+
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Define log level for this file: OFF, ERROR, WARN, INFO, VERBOSE
|
7
|
+
* See YapDatabaseLogging.h for more information.
|
8
|
+
**/
|
9
|
+
#if DEBUG
|
10
|
+
static const int ydbLogLevel = YDB_LOG_LEVEL_OFF;
|
11
|
+
#else
|
12
|
+
static const int ydbLogLevel = YDB_LOG_LEVEL_OFF;
|
13
|
+
#endif
|
14
|
+
|
15
|
+
/**
|
16
|
+
* Default countLimit, as specified in header file.
|
17
|
+
**/
|
18
|
+
#define YAP_CACHE_DEFAULT_COUNT_LIMIT 40
|
19
|
+
|
20
|
+
|
21
|
+
@interface YapCacheItem : NSObject {
|
22
|
+
@public
|
23
|
+
__unsafe_unretained YapCacheItem *prev; // retained by cfdict
|
24
|
+
__unsafe_unretained YapCacheItem *next; // retained by cfdict
|
25
|
+
|
26
|
+
__unsafe_unretained id key; // retained by cfdict as key
|
27
|
+
__strong id value; // retained only by us
|
28
|
+
}
|
29
|
+
|
30
|
+
- (id)initWithKey:(id)key value:(id)value;
|
31
|
+
|
32
|
+
@end
|
33
|
+
|
34
|
+
@implementation YapCacheItem
|
35
|
+
|
36
|
+
- (id)initWithKey:(id <NSCopying>)aKey value:(id)aValue
|
37
|
+
{
|
38
|
+
if ((self = [super init]))
|
39
|
+
{
|
40
|
+
key = aKey;
|
41
|
+
value = aValue;
|
42
|
+
}
|
43
|
+
return self;
|
44
|
+
}
|
45
|
+
|
46
|
+
- (NSString *)description
|
47
|
+
{
|
48
|
+
return [NSString stringWithFormat:@"<YapCacheItem[%p] key(%@)>", self, key];
|
49
|
+
}
|
50
|
+
|
51
|
+
@end
|
52
|
+
|
53
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
54
|
+
#pragma mark -
|
55
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
56
|
+
|
57
|
+
@implementation YapCache
|
58
|
+
{
|
59
|
+
Class keyClass;
|
60
|
+
CFMutableDictionaryRef cfdict;
|
61
|
+
|
62
|
+
NSUInteger countLimit;
|
63
|
+
|
64
|
+
__unsafe_unretained YapCacheItem *mostRecentCacheItem;
|
65
|
+
__unsafe_unretained YapCacheItem *leastRecentCacheItem;
|
66
|
+
|
67
|
+
__strong YapCacheItem *evictedCacheItem;
|
68
|
+
|
69
|
+
#if YAP_CACHE_STATISTICS
|
70
|
+
NSUInteger hitCount;
|
71
|
+
NSUInteger missCount;
|
72
|
+
NSUInteger evictionCount;
|
73
|
+
#endif
|
74
|
+
}
|
75
|
+
|
76
|
+
#if YAP_CACHE_STATISTICS
|
77
|
+
@synthesize hitCount = hitCount;
|
78
|
+
@synthesize missCount = missCount;
|
79
|
+
@synthesize evictionCount = evictionCount;
|
80
|
+
#endif
|
81
|
+
|
82
|
+
- (id)init
|
83
|
+
{
|
84
|
+
return [self initWithKeyClass:NULL countLimit:0];
|
85
|
+
}
|
86
|
+
|
87
|
+
- (id)initWithKeyClass:(Class)inKeyClass
|
88
|
+
{
|
89
|
+
return [self initWithKeyClass:inKeyClass countLimit:0];
|
90
|
+
}
|
91
|
+
|
92
|
+
- (id)initWithKeyClass:(Class)inKeyClass countLimit:(NSUInteger)inCountLimit
|
93
|
+
{
|
94
|
+
if ((self = [super init]))
|
95
|
+
{
|
96
|
+
if (inKeyClass == NULL)
|
97
|
+
keyClass = [NSString class];
|
98
|
+
else
|
99
|
+
keyClass = inKeyClass;
|
100
|
+
|
101
|
+
if (inCountLimit == 0)
|
102
|
+
countLimit = YAP_CACHE_DEFAULT_COUNT_LIMIT;
|
103
|
+
else
|
104
|
+
countLimit = inCountLimit;
|
105
|
+
|
106
|
+
// We actually use countLimit plus one.
|
107
|
+
// This is because we evict items after the count surpasses the countLimit.
|
108
|
+
// In other words, we evict items when the count reaches countLimit plus one.
|
109
|
+
|
110
|
+
cfdict = CFDictionaryCreateMutable(kCFAllocatorDefault,
|
111
|
+
0,
|
112
|
+
&kCFTypeDictionaryKeyCallBacks,
|
113
|
+
&kCFTypeDictionaryValueCallBacks);
|
114
|
+
}
|
115
|
+
return self;
|
116
|
+
}
|
117
|
+
|
118
|
+
- (void)dealloc
|
119
|
+
{
|
120
|
+
if (cfdict) CFRelease(cfdict);
|
121
|
+
}
|
122
|
+
|
123
|
+
- (NSUInteger)countLimit
|
124
|
+
{
|
125
|
+
return countLimit;
|
126
|
+
}
|
127
|
+
|
128
|
+
- (void)setCountLimit:(NSUInteger)newCountLimit
|
129
|
+
{
|
130
|
+
if (countLimit != newCountLimit)
|
131
|
+
{
|
132
|
+
countLimit = newCountLimit;
|
133
|
+
|
134
|
+
if (countLimit != 0) {
|
135
|
+
while (CFDictionaryGetCount(cfdict) > countLimit)
|
136
|
+
{
|
137
|
+
leastRecentCacheItem->prev->next = nil;
|
138
|
+
|
139
|
+
evictedCacheItem = leastRecentCacheItem;
|
140
|
+
leastRecentCacheItem = leastRecentCacheItem->prev;
|
141
|
+
|
142
|
+
CFDictionaryRemoveValue(cfdict, (const void *)(evictedCacheItem->key));
|
143
|
+
|
144
|
+
evictedCacheItem->prev = nil;
|
145
|
+
evictedCacheItem->next = nil;
|
146
|
+
evictedCacheItem->key = nil;
|
147
|
+
evictedCacheItem->value = nil;
|
148
|
+
|
149
|
+
#if YAP_CACHE_STATISTICS
|
150
|
+
evictionCount++;
|
151
|
+
#endif
|
152
|
+
}
|
153
|
+
}
|
154
|
+
}
|
155
|
+
}
|
156
|
+
|
157
|
+
- (id)objectForKey:(id)key
|
158
|
+
{
|
159
|
+
NSAssert([key isKindOfClass:keyClass], @"Unexpected key class. Expected %@, passed %@", keyClass, [key class]);
|
160
|
+
|
161
|
+
YapCacheItem *item = CFDictionaryGetValue(cfdict, (const void *)key);
|
162
|
+
if (item)
|
163
|
+
{
|
164
|
+
if (item != mostRecentCacheItem)
|
165
|
+
{
|
166
|
+
// Remove item from current position in linked-list.
|
167
|
+
//
|
168
|
+
// Notes:
|
169
|
+
// We fetched the item from the list,
|
170
|
+
// so we know there's a valid mostRecentCacheItem & leastRecentCacheItem.
|
171
|
+
// Furthermore, we know the item isn't the mostRecentCacheItem.
|
172
|
+
|
173
|
+
item->prev->next = item->next;
|
174
|
+
|
175
|
+
if (item == leastRecentCacheItem)
|
176
|
+
leastRecentCacheItem = item->prev;
|
177
|
+
else
|
178
|
+
item->next->prev = item->prev;
|
179
|
+
|
180
|
+
// Move item to beginning of linked-list
|
181
|
+
|
182
|
+
item->prev = nil;
|
183
|
+
item->next = mostRecentCacheItem;
|
184
|
+
|
185
|
+
mostRecentCacheItem->prev = item;
|
186
|
+
mostRecentCacheItem = item;
|
187
|
+
}
|
188
|
+
|
189
|
+
#if YAP_CACHE_STATISTICS
|
190
|
+
hitCount++;
|
191
|
+
#endif
|
192
|
+
return item->value;
|
193
|
+
}
|
194
|
+
else
|
195
|
+
{
|
196
|
+
#if YAP_CACHE_STATISTICS
|
197
|
+
missCount++;
|
198
|
+
#endif
|
199
|
+
return nil;
|
200
|
+
}
|
201
|
+
}
|
202
|
+
|
203
|
+
- (BOOL)containsKey:(id)key
|
204
|
+
{
|
205
|
+
NSAssert([key isKindOfClass:keyClass], @"Unexpected key class. Expected %@, passed %@", keyClass, [key class]);
|
206
|
+
|
207
|
+
return CFDictionaryContainsKey(cfdict, (const void *)key);
|
208
|
+
}
|
209
|
+
|
210
|
+
- (void)setObject:(id)object forKey:(id)key
|
211
|
+
{
|
212
|
+
NSAssert([key isKindOfClass:keyClass], @"Unexpected key class. Expected %@, passed %@", keyClass, [key class]);
|
213
|
+
|
214
|
+
YapCacheItem *item = CFDictionaryGetValue(cfdict, (const void *)key);
|
215
|
+
if (item)
|
216
|
+
{
|
217
|
+
// Update item value
|
218
|
+
item->value = object;
|
219
|
+
|
220
|
+
if (item != mostRecentCacheItem)
|
221
|
+
{
|
222
|
+
// Remove item from current position in linked-list
|
223
|
+
//
|
224
|
+
// Notes:
|
225
|
+
// We fetched the item from the list,
|
226
|
+
// so we know there's a valid mostRecentCacheItem & leastRecentCacheItem.
|
227
|
+
// Furthermore, we know the item isn't the mostRecentCacheItem.
|
228
|
+
|
229
|
+
item->prev->next = item->next;
|
230
|
+
|
231
|
+
if (item == leastRecentCacheItem)
|
232
|
+
leastRecentCacheItem = item->prev;
|
233
|
+
else
|
234
|
+
item->next->prev = item->prev;
|
235
|
+
|
236
|
+
// Move item to beginning of linked-list
|
237
|
+
|
238
|
+
item->prev = nil;
|
239
|
+
item->next = mostRecentCacheItem;
|
240
|
+
|
241
|
+
mostRecentCacheItem->prev = item;
|
242
|
+
mostRecentCacheItem = item;
|
243
|
+
|
244
|
+
YDBLogVerbose(@"key(%@) <- existing, new mostRecent", key);
|
245
|
+
}
|
246
|
+
else
|
247
|
+
{
|
248
|
+
YDBLogVerbose(@"key(%@) <- existing, already mostRecent", key);
|
249
|
+
}
|
250
|
+
}
|
251
|
+
else
|
252
|
+
{
|
253
|
+
// Create new item (or recycle old evicted item)
|
254
|
+
|
255
|
+
if (evictedCacheItem)
|
256
|
+
{
|
257
|
+
item = evictedCacheItem;
|
258
|
+
item->key = key;
|
259
|
+
item->value = object;
|
260
|
+
|
261
|
+
evictedCacheItem = nil;
|
262
|
+
}
|
263
|
+
else
|
264
|
+
{
|
265
|
+
item = [[YapCacheItem alloc] initWithKey:key value:object];
|
266
|
+
}
|
267
|
+
|
268
|
+
// Add item to set
|
269
|
+
CFDictionarySetValue(cfdict, (const void *)key, (const void *)item);
|
270
|
+
|
271
|
+
// Add item to beginning of linked-list
|
272
|
+
|
273
|
+
item->next = mostRecentCacheItem;
|
274
|
+
|
275
|
+
if (mostRecentCacheItem)
|
276
|
+
mostRecentCacheItem->prev = item;
|
277
|
+
|
278
|
+
mostRecentCacheItem = item;
|
279
|
+
|
280
|
+
// Evict leastRecentCacheItem if needed
|
281
|
+
|
282
|
+
if ((countLimit != 0) && (CFDictionaryGetCount(cfdict) > countLimit))
|
283
|
+
{
|
284
|
+
YDBLogVerbose(@"key(%@), out(%@)", key, leastRecentCacheItem->key);
|
285
|
+
|
286
|
+
leastRecentCacheItem->prev->next = nil;
|
287
|
+
|
288
|
+
evictedCacheItem = leastRecentCacheItem;
|
289
|
+
leastRecentCacheItem = leastRecentCacheItem->prev;
|
290
|
+
|
291
|
+
CFDictionaryRemoveValue(cfdict, (const void *)(evictedCacheItem->key));
|
292
|
+
|
293
|
+
evictedCacheItem->prev = nil;
|
294
|
+
evictedCacheItem->next = nil;
|
295
|
+
evictedCacheItem->key = nil;
|
296
|
+
evictedCacheItem->value = nil;
|
297
|
+
|
298
|
+
#if YAP_CACHE_STATISTICS
|
299
|
+
evictionCount++;
|
300
|
+
#endif
|
301
|
+
}
|
302
|
+
else
|
303
|
+
{
|
304
|
+
if (leastRecentCacheItem == nil)
|
305
|
+
leastRecentCacheItem = item;
|
306
|
+
|
307
|
+
YDBLogVerbose(@"key(%@) <- new, new mostRecent [%ld of %lu]",
|
308
|
+
key, CFDictionaryGetCount(cfdict), (unsigned long)countLimit);
|
309
|
+
}
|
310
|
+
}
|
311
|
+
|
312
|
+
if (ydbLogLevel & YDB_LOG_FLAG_VERBOSE)
|
313
|
+
{
|
314
|
+
YDBLogVerbose(@"cfdict: %@", cfdict);
|
315
|
+
|
316
|
+
YapCacheItem *loopItem = mostRecentCacheItem;
|
317
|
+
NSUInteger i = 0;
|
318
|
+
|
319
|
+
while (loopItem != nil)
|
320
|
+
{
|
321
|
+
YDBLogVerbose(@"%lu: %@", (unsigned long)i, loopItem);
|
322
|
+
|
323
|
+
loopItem = loopItem->next;
|
324
|
+
i++;
|
325
|
+
}
|
326
|
+
}
|
327
|
+
}
|
328
|
+
|
329
|
+
- (NSUInteger)count
|
330
|
+
{
|
331
|
+
return CFDictionaryGetCount(cfdict);
|
332
|
+
}
|
333
|
+
|
334
|
+
- (void)removeAllObjects
|
335
|
+
{
|
336
|
+
mostRecentCacheItem = nil;
|
337
|
+
leastRecentCacheItem = nil;
|
338
|
+
evictedCacheItem = nil;
|
339
|
+
|
340
|
+
CFDictionaryRemoveAllValues(cfdict);
|
341
|
+
}
|
342
|
+
|
343
|
+
- (void)removeObjectForKey:(id)key
|
344
|
+
{
|
345
|
+
NSAssert([key isKindOfClass:keyClass], @"Unexpected key class. Expected %@, passed %@", keyClass, [key class]);
|
346
|
+
|
347
|
+
YapCacheItem *item = CFDictionaryGetValue(cfdict, (const void *)key);
|
348
|
+
if (item)
|
349
|
+
{
|
350
|
+
if (item->prev)
|
351
|
+
item->prev->next = item->next;
|
352
|
+
|
353
|
+
if (item->next)
|
354
|
+
item->next->prev = item->prev;
|
355
|
+
|
356
|
+
if (mostRecentCacheItem == item)
|
357
|
+
mostRecentCacheItem = item->next;
|
358
|
+
|
359
|
+
if (leastRecentCacheItem == item)
|
360
|
+
leastRecentCacheItem = item->prev;
|
361
|
+
|
362
|
+
CFDictionaryRemoveValue(cfdict, (const void *)key);
|
363
|
+
}
|
364
|
+
}
|
365
|
+
|
366
|
+
- (void)removeObjectsForKeys:(NSArray *)keys
|
367
|
+
{
|
368
|
+
for (id key in keys)
|
369
|
+
{
|
370
|
+
NSAssert([key isKindOfClass:keyClass], @"Unexpected key class. Expected %@, passed %@", keyClass, [key class]);
|
371
|
+
|
372
|
+
YapCacheItem *item = CFDictionaryGetValue(cfdict, (const void *)key);
|
373
|
+
if (item)
|
374
|
+
{
|
375
|
+
if (item->prev)
|
376
|
+
item->prev->next = item->next;
|
377
|
+
|
378
|
+
if (item->next)
|
379
|
+
item->next->prev = item->prev;
|
380
|
+
|
381
|
+
if (mostRecentCacheItem == item)
|
382
|
+
mostRecentCacheItem = item->next;
|
383
|
+
|
384
|
+
if (leastRecentCacheItem == item)
|
385
|
+
leastRecentCacheItem = item->prev;
|
386
|
+
|
387
|
+
CFDictionaryRemoveValue(cfdict, (const void *)key);
|
388
|
+
}
|
389
|
+
}
|
390
|
+
}
|
391
|
+
|
392
|
+
- (void)enumerateKeysWithBlock:(void (^)(id key, BOOL *stop))block
|
393
|
+
{
|
394
|
+
NSDictionary *nsdict = (__bridge NSDictionary *)cfdict;
|
395
|
+
BOOL stop = NO;
|
396
|
+
|
397
|
+
for (id key in [nsdict keyEnumerator])
|
398
|
+
{
|
399
|
+
block(key, &stop);
|
400
|
+
|
401
|
+
if (stop) break;
|
402
|
+
}
|
403
|
+
}
|
404
|
+
|
405
|
+
- (NSString *)description
|
406
|
+
{
|
407
|
+
NSMutableString *description = [NSMutableString string];
|
408
|
+
[description appendFormat:@"%@, count=%ld, keys=\n", NSStringFromClass([self class]), CFDictionaryGetCount(cfdict)];
|
409
|
+
|
410
|
+
YapCacheItem *item = mostRecentCacheItem;
|
411
|
+
NSUInteger itemIndex = 0;
|
412
|
+
|
413
|
+
while (item != nil)
|
414
|
+
{
|
415
|
+
[description appendFormat:@" %lu: %@\n", (unsigned long)itemIndex, item->key];
|
416
|
+
|
417
|
+
item = item->next;
|
418
|
+
itemIndex++;
|
419
|
+
}
|
420
|
+
|
421
|
+
return description;
|
422
|
+
}
|
423
|
+
|
424
|
+
/*
|
425
|
+
- (void)debug
|
426
|
+
{
|
427
|
+
CFIndex count = CFDictionaryGetCount(cfdict);
|
428
|
+
NSAssert(count <= countLimit, @"Invalid count");
|
429
|
+
|
430
|
+
NSMutableArray *forwardsKeys = [NSMutableArray arrayWithCapacity:count];
|
431
|
+
NSMutableArray *backwardsKeys = [NSMutableArray arrayWithCapacity:count];
|
432
|
+
|
433
|
+
__unsafe_unretained YapCacheItem *loopItem;
|
434
|
+
|
435
|
+
loopItem = mostRecentCacheItem;
|
436
|
+
while (loopItem != nil)
|
437
|
+
{
|
438
|
+
[forwardsKeys addObject:loopItem->key];
|
439
|
+
loopItem = loopItem->next;
|
440
|
+
}
|
441
|
+
|
442
|
+
loopItem = leastRecentCacheItem;
|
443
|
+
while (loopItem != nil)
|
444
|
+
{
|
445
|
+
[backwardsKeys insertObject:loopItem->key atIndex:0];
|
446
|
+
loopItem = loopItem->prev;
|
447
|
+
}
|
448
|
+
|
449
|
+
NSAssert([forwardsKeys isEqual:backwardsKeys], @"Invalid order");
|
450
|
+
}
|
451
|
+
*/
|
452
|
+
|
453
|
+
@end
|