diff --git a/.gitignore b/.gitignore index 4d2a4d6d..607fc424 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,53 @@ pubspec.lock # Directory created by dartdoc # If you don't generate documentation locally you can remove this line. doc/api/ +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/dictionaries + +# Sensitive or high-churn files: +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.xml +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml + +# Gradle: +.idea/**/gradle.xml +.idea/**/libraries + +# CMake +cmake-build-debug/ + +# Mongo Explorer plugin: +.idea/**/mongoSettings.xml + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties diff --git a/.idea/cache.iml b/.idea/cache.iml new file mode 100644 index 00000000..0fd729f3 --- /dev/null +++ b/.idea/cache.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..c1f1e7f8 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/lib/angel_cache.dart b/lib/angel_cache.dart new file mode 100644 index 00000000..3a8ef9cf --- /dev/null +++ b/lib/angel_cache.dart @@ -0,0 +1,21 @@ +import 'package:angel_framework/angel_framework.dart'; +import 'package:meta/meta.dart'; + +/// An Angel [Service] that caches data from another service. +/// +/// This is useful for applications of scale, where network latency +/// can have real implications on application performance. +class CacheService extends Service { + /// The underlying [Service] that represents the original data store. + final Service database; + + /// The [Service] used to interface with a caching layer. + /// + /// If not provided, this defaults to a [MapService]. + final Service cache; + + CacheService({@required this.database, Service cache}) + : this.cache = cache ?? new MapService() { + assert(database != null); + } +} diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 00000000..c3e683ee --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,7 @@ +name: angel_cache +dependencies: + angel_framework: ">=1.0.0-dev <2.0.0" + meta: ^1.0.0 +dev_dependencies: + angel_test: ^1.1.0 + test: ^0.12.0 \ No newline at end of file