Skip to content

Commit

Permalink
Disable caching
Browse files Browse the repository at this point in the history
  • Loading branch information
svilupp committed Jul 12, 2024
2 parents b57a272 + 4cf1c23 commit d30a605
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- Added a launcher function `launch` to make it easier to launch the app.
- Semantic caching enabled by SemanticCaches.jl. You can change it by setting `cached=false` in the `launch()` function (minimum similarity for cache hit is 0.99).
- Semantic caching provided by SemanticCaches.jl. You can change it by setting `cached=false` in the `launch()` function. It's disabled by default.

### Fixed
- Fixed a bug when caching would error for certain types of HTTP body (eg, `IOBuffer`)
Expand Down
2 changes: 1 addition & 1 deletion main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ Pkg.activate(".")
## Required to support semantic caching
ENV["DATADEPS_ALWAYS_ACCEPT"] = "true"
using ProToPortal
ProToPortal.launch(8000, "0.0.0.0"; async = false, cached = true, cache_verbose = true)
ProToPortal.launch(8000, "0.0.0.0"; async = false, cached = false, cache_verbose = false)
9 changes: 5 additions & 4 deletions src/server.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
launch(
port::Int = get(ENV, "PORT", 8000), host::String = get(
ENV, "GENIE_HOST", "127.0.0.1");
async::Bool = true, cached::Bool = true, cache_verbose::Bool = false)
async::Bool = true, cached::Bool = false, cache_verbose::Bool = false)
Launches ProToPortal in the browser.
Expand All @@ -13,20 +13,21 @@ This is a convenience wrapper around `Genie.up`, to customize the server configu
- `port::Union{Int, String} = get(ENV, "PORT", "8000")`: The port to launch the server on.
- `host::String = get(ENV, "GENIE_HOST", "127.0.0.1")`: The host to launch the server on.
- `async::Bool = true`: Whether to launch the server asynchronously, ie, in the background.
- `cached::Bool = true`: Whether to use semantic caching of the requests.
- `cache_verbose::Bool = true`: Whether to print verbose information about the caching process.
- `cached::Bool = false`: Whether to use semantic caching of the requests.
- `cache_verbose::Bool = false`: Whether to print verbose information about the caching process.
If you want to remove the cache layer later, you can use `import HTTP; HTTP.poplayer!()`.
"""
function launch(
port::Union{Int, String} = get(ENV, "PORT", "8000"),
host::String = get(ENV, "GENIE_HOST", "127.0.0.1");
async::Bool = true, cached::Bool = true, cache_verbose::Bool = true)
async::Bool = true, cached::Bool = false, cache_verbose::Bool = false)
## Loads app.jl in the root directory
Genie.loadapp(pkgdir(ProToPortal))

## Enables caching
ENV["CACHES_VERBOSE"] = cache_verbose ? "true" : "false"
## disable until we can do length-adjusted semantic distance
if cached
@info "Caching enabled globally (for all requests, see `CacheLayer` module for details). Remove with `HTTP.poplayer!()`"
HTTP.pushlayer!(CacheLayer.cache_layer)
Expand Down

0 comments on commit d30a605

Please sign in to comment.