Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds EndpointCache for handling GET resource caching #2184

Merged
merged 9 commits into from
Feb 17, 2020
Merged

Conversation

grosch
Copy link
Contributor

@grosch grosch commented Feb 15, 2020

Adds EndpointCache which can be used to handle GET requests which are cache aware.

let endpoint = EndpointCache<MyDataType>(uri: "https://foo.dev/path/to/resource")

endpoint.get(on: req) { data in 
    // Access cached data.
}

This class is thread-safe and will only cache one copy of the resource per event loop.

@tanner0101 tanner0101 added the enhancement New feature or request label Feb 15, 2020
@tanner0101 tanner0101 added this to In Progress in Vapor 4 via automation Feb 15, 2020
Copy link
Member

@tanner0101 tanner0101 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Sources/Vapor/HTTP/EndpointCache.swift Outdated Show resolved Hide resolved
Sources/Vapor/HTTP/EndpointCache.swift Outdated Show resolved Hide resolved
Sources/Vapor/HTTP/EndpointCache.swift Outdated Show resolved Hide resolved
Sources/Vapor/HTTP/EndpointCache.swift Outdated Show resolved Hide resolved
Sources/Vapor/HTTP/EndpointCache.swift Outdated Show resolved Hide resolved
Sources/Vapor/HTTP/EndpointCache.swift Outdated Show resolved Hide resolved
Sources/Vapor/HTTP/EndpointCache.swift Outdated Show resolved Hide resolved
Copy link
Member

@tanner0101 tanner0101 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on this one 👍

Sources/Vapor/HTTP/EndpointCache.swift Outdated Show resolved Hide resolved
@tanner0101 tanner0101 added the semver-minor Contains new API label Feb 15, 2020
@tanner0101 tanner0101 changed the title Adds a generic EndpointCache<T> class Adds EndpointCache<T> Feb 15, 2020
@tanner0101 tanner0101 changed the title Adds EndpointCache<T> EndpointCache for handling GET resource caching Feb 15, 2020
@tanner0101 tanner0101 changed the title EndpointCache for handling GET resource caching Adds EndpointCache for handling GET resource caching Feb 15, 2020
@0xTim
Copy link
Member

0xTim commented Feb 16, 2020

Tests needed... 😉

@tanner0101 tanner0101 merged commit c1f9162 into master Feb 17, 2020
Vapor 4 automation moved this from In Progress to Done Feb 17, 2020
@tanner0101 tanner0101 deleted the endpointCache branch February 17, 2020 20:36
@tanner0101
Copy link
Member

tanner0101 commented Feb 17, 2020

These changes are now available in https://github.com/vapor/vapor/releases/tag/4.0.0-beta.3.20

mohpor pushed a commit to mohpor/vapor that referenced this pull request Feb 18, 2020
* Adds a generic EndpointCache<T> class

* Review fixups

* Changed internal to private

* Changed internal to private

* Renamed the error

* add EndpointCache tests

* add CacheControl convienience init

* rename badJSON error case

Co-authored-by: Tanner <me@tanner.xyz>
tanner0101 added a commit that referenced this pull request Feb 19, 2020
* Added CaseOf Validation with tests

Signed-off-by: Mohammad <porooshani@gmail.com>

* Changed caseOf to case and improved error messages and updated tests.

Signed-off-by: Mohammad <porooshani@gmail.com>

* Removed non-CaseIterable support from case(of:) validation.

Signed-off-by: Mohammad <porooshani@gmail.com>

* Removed unwanted map in error generator

Signed-off-by: Mohammad <porooshani@gmail.com>

* Improved error Generation.

Signed-off-by: Mohammad <porooshani@gmail.com>

* Add myself as a maintainer (#2188)

* Adds EndpointCache for handling GET resource caching (#2184)

* Adds a generic EndpointCache<T> class

* Review fixups

* Changed internal to private

* Changed internal to private

* Renamed the error

* add EndpointCache tests

* add CacheControl convienience init

* rename badJSON error case

Co-authored-by: Tanner <me@tanner.xyz>

* expose methods for hex encoded strings (#2189)

* Removed non-CaseIterable support from case(of:) validation.

Signed-off-by: Mohammad <porooshani@gmail.com>

* Removed unwanted map in error generator

Signed-off-by: Mohammad <porooshani@gmail.com>

* Improved error Generation.

Signed-off-by: Mohammad <porooshani@gmail.com>

* Improved description message for case(of:)

Signed-off-by: Mohammad <porooshani@gmail.com>

Co-authored-by: Joannis Orlandos <joannis@orlandos.nl>
Co-authored-by: grosch <scott.grosch@icloud.com>
Co-authored-by: Tanner <me@tanner.xyz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request semver-minor Contains new API
Projects
Vapor 4
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants