module

Fetcher::Reddit

Constants

HTTP_STATUS_WIDTH = 80

Diagnostics and response formatting constants

MAX_BODY_SNIPPET = 512
OLD_REDDIT_API_BASE = "https://old.reddit.com"
OLD_REDDIT_TTLS = {"new" => 5.minutes, "rising" => 5.minutes, "hot" => 15.minutes, "top" => 30.minutes, "controversial" => 30.minutes, "default" => 15.minutes}
REDDIT_API_BASE = "https://www.reddit.com"
REDDIT_TTLS = {"new" => 30.seconds, "rising" => 30.seconds, "hot" => 2.minutes, "top" => 10.minutes, "controversial" => 10.minutes}

Data-driven TTLs for caching by sort and backend

USER_AGENT = "fetcher.cr/0.9.7 (https://github.com/kritoke/fetcher.cr; 3081486+kritoke@users.noreply.github.com)"
VALID_SORTS = {"hot", "new", "rising", "top", "controversial"}
VALID_SUBREDDIT = /^[A-Za-z0-9_+%]+$/

Class methods

clear_cache(subreddit : String) : Nil
Source
generate_cache_key(subreddit : String, sort : String, limit : Int32) : String
Source
old_ttl_for_sort(sort : String) : Time::Span
Source
parse_reddit_response(body : String, limit : Int32) : Array(Entry)
Source
pull(url : String, headers : HTTP::Headers, limit : Int32 = 100, config : RequestConfig = RequestConfig.new) : Result
Source
ttl_for_sort(sort : String) : Time::Span
Source

Nested types