def cache_url(url): """Adds a url to the cache. Returns True if we've seen it before or False if it's new.""" url_store = KVStore.getCustomStore("tumblr_urls") if url_store.has(url): return True else: url_store.save(url, time.time()) return False
def cache_search(search): """Adds a search to the cache. Returns True if we've seen it before or False if it's new.""" tokens = re.sub("[^a-z\s]", "", search.lower()).split() key = " ".join(sorted(tokens)) search_store = KVStore.getCustomStore("tumblr_searches") if search_store.has(key): return True else: search_store.save(key, time.time()) return False
def set_last_post_time(): store = KVStore.getCustomStore("tumblr") now = time.time() last_post = store.save("lastPost", now) return now
def get_last_post_time(): store = KVStore.getCustomStore("tumblr") last_post = store.getOrElse("lastPost", 0.0) return last_post
def get_tumblr_store(): store = KVStore.getCustomStore("tumblr") return store