Giter Club home page Giter Club logo

carlos's People

Contributors

asalom avatar bkase avatar esad avatar minhoryang avatar phimage avatar toupper avatar vittoriom avatar whoover avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

carlos's Issues

Cap parallel requests on CacheLevel

First mvp would be to have some queue on the network fetcher where the requests are dispatched, and the queue could have a given maxNumberOfConcurrentOperations. To do so, though, Request objects should be NSOperations and this would complicate things. Another way is to have a generic RequestCapper class that takes a number and a cache and "counts" the number of ongoing requests decrementing it only when onSuccess or onFailure is called. This should work on all CacheLevels and doesn't require any change in a specific CacheLevel like the NetworkFetcher.

More documentation

Document more classes in the codebase so that the automatic documentation generated by CocoaPods is more pleasant to browse

Overhaul of the cache architecture

If, instead of using a list of CacheLevels, we use a composition of CacheLevels, where each takes a type and outputs another (not necessarily different) type, we could have both a generic cache that stores whatever type (not only NSData), but more than that we could have an integrated transformation mechanism that lets single levels manipulate data depending on their internal details.

Add helper functions for most common caches

It would be nice to add some public functions or maybe one helper class with a couple of methods on it, to create the most common caches (e.g. Memory -> Disk -> Network)

This way one doesn't have to always write the boilerplate code for simple usages

Introduce a CacheRequest return type for the get method

The CacheRequest should be a generic protocol with the following functions:

public protocol CacheRequest {
  typealias KeyType
  typealias OutputType

  func cancel()
  func onFailure(NSError? -> Void)
  func onSuccess(OutputType -> Void)
}

this way we could get rid of the success and failure parameters passed to all the basic caches and composition/transformation operators, and just use the request object instead.
Moreover, we would get free support to canceling requests (for example expensive network requests), and easier support to request pooling.

Rewrite unit tests with Quick and Nimble instead of XCTest

BasicCache (✓)
CacheRequest (✓)
Composition (✓)
Conditioning (✓)
Pooling (✓)
DiskCache (✓)
MemoryCache (✓)
NetworkCache (next release)
Extensions (✓)
Memory warning (✓)
Key transformation (✓)
Value transformation (✓)
OneWayTransformer (✓)
TwoWayTransformer (✓)

Documentation improvement suggestions

I just read the README.md and like the detailed documentation. I only have two questions left:

  1. The project's description is "A simple but flexible cache".
    What about making it more specific, e.g. "A simple but flexible cache for iOS Swift apps"
  2. The requirements mentioned in the README.md: are:
  3. iOS 8.0+
  4. Xcode 6.3
    I would interpret this as that Carlos only works with Xcode 6.3, and does not work with Xcode 6.4. If my interpretation is wrong, I suggest writing "Xcode 6.3+"

Setup a Playground to quickly test Carlos

Is it possible to setup a playground that imports a Framework? Otherwise, just import all the Carlos files.
But it would be nice to have a simple playground where one can create caches, levels and see how the operators, functions and closures work together

Add output transformers

Similar to value transformers, introduce "output transformers", that transform values of one type to values of the same type but apply some logic on top (for example resize images, sanitize strings, etc). These transformers can be chained to CacheLevels and will affect the data that will be returned by get requests, but not the data that will be saved on set requests, as it happens for normal value transformers.

Dispatch requests on a given queue

Ideally there would be a class, an operator and some protocol extension that let the user specify on which queue the requests should be dispatched.

  • Basic API
  • Implement protocol extension / operator
  • Add tests
  • Write code documentation
  • Add sample code
  • Update README.md
  • Update Wiki
  • Update CHANGELOG.md
  • Update Github milestone

Add a SwitchCache level

The SwitchCache level is an object that takes 2 equivalent caches (same key, same value) and a condition closure that takes the key and has to return either one cache or the other. This way one could setup two different cache "lanes" and choose the lane depending on the key or some external condition.

  • Implement feature (✓)
  • Add tests (✓)
  • Add samples (✓)
  • Update README (✓)

Add custom logger functionality for CacheLevels

Basic idea is that every CacheLevel has its own logger reference. Logger is a protocol with a log function.

Breakdown would be:

public enum LogLevel {
    case Debug, Info, Warning, Error, Fatal, None  
}

public protocol Logger {
    func log(message: String, level: LogLevel)
}

and then

public protocol CacheLevel {
   [...]

   func setLogger(logger: Logger)
}

Then one can call setLogger on whatever CacheLevel (for example the top-most, that will set the logger to all its managed cache levels, or whichever you need to).

Define a root level Cache<A,B>

All specific caches (Pool, RequestCapper, Basic, etc) should subclass this class so that creating complex cache levels doesn't result in an unreadable inferred type.

Make transformers safer

Transformers should be able to return optional values, so that if they fail the cache level will be skipped and the get/set will be treated as a failure.

Extend CacheRequest to be *LiteralConvertible

It would be great if the user could directly return literal values when implementing get when creating custom levels or fetch closures.
To do this, CacheRequest has to extend *LiteralConvertible (String, Integer, etc.).
Question: is it possible to do it for a generic class?
In case it is, implement and update README.md

Better support to create pooled caches

An infix operator would do the trick, but then we'd have to find a good one. Otherwise, I was thinking at a fake cache level result of a pooled() free function that, combined with the usual >>> composition operator, would actually call the pooled(_) function, through an overloading of the >>> operator. But that's also quite weird.

Other options?

Write a sample app that shows Carlos capabilities

Things to show:

  • Simple cache with one layer (✓)
  • Multi-layer cache including fetch closures (✓)
  • Complex multi-layer cache with key and value transformations (✓)
  • Requests pool (✓)
  • Conditioned caches (✓)
  • Requests capped cache (✓)
  • Closures usage in transformers and fetchers (✓)
  • Operators vs functions (✓)

Improve NetworkFetcher

Right now NetworkFetcher has set, clear and onMemoryWarning methods that are no-ops. Maybe we could make the NetworkFetcher a fetch closure instead of a full-blown cache level.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.