src/newseasons/models/shows.clj @ a77d48fb4f63
Add a set of shows to check.
author |
Steve Losh <steve@stevelosh.com> |
date |
Mon, 03 Oct 2011 20:47:22 -0400 |
parents |
fb4c1da11613 |
children |
89f24149ecd7 |
(ns newseasons.models.shows
(:use newseasons.models.keys)
(:use [aleph.redis :only (redis-client)]))
(def r (redis-client {:host "localhost" :password "devpass"}))
; "Schema" --------------------------------------------------------------------
;
; Shows are stored as hashes.
;
; shows:<iTunes artist ID> = {
; id: show id
; title: show tile
; latest: description of the latest season
; image: url to show's image
; url: url to view the show on iTunes
; }
;
; The shows we need to check are stored in two places for durability and ease of
; use:
;
; shows:to-check = z#{<iTunes artist ID>, ...}
; shows:to-check:queue = [<iTunes artist ID, ...]
; push to --^ ^-- pop from
; Code ------------------------------------------------------------------------
(defn show-get [id]
(let [show (apply hash-map @(r [:hgetall (key-show id)]))]
(when (not (empty? show))
{:id (show "id")
:title (show "title")
:image (show "image")
:latest (show "latest")
:url (show "url")})))
(defn show-set-id! [id new-id]
@(r [:hset (key-show id) "id" new-id]))
(defn show-set-title! [id new-title]
@(r [:hset (key-show id) "title" new-title]))
(defn show-set-latest! [id new-latest]
@(r [:hset (key-show id) "latest" new-latest]))
(defn show-set-image! [id new-image]
@(r [:hset (key-show id) "image" new-image]))
(defn show-set-url! [id new-url]
@(r [:hset (key-show id) "url" new-url]))
(defn show-add-to-checked! [id]
@(r [:sadd "shows:to-check" id]))