Exemplo n.º 1
0
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
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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
Exemplo n.º 4
0
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
Exemplo n.º 5
0
def set_last_post_time():
    store = KVStore.getCustomStore("tumblr")
    now = time.time()
    last_post = store.save("lastPost", now)
    return now
Exemplo n.º 6
0
def get_last_post_time():
    store = KVStore.getCustomStore("tumblr")
    last_post = store.getOrElse("lastPost", 0.0)
    return last_post
Exemplo n.º 7
0
def get_tumblr_store():
    store = KVStore.getCustomStore("tumblr")
    return store
Exemplo n.º 8
0
def set_last_post_time():
    store = KVStore.getCustomStore("tumblr")
    now = time.time()
    last_post = store.save("lastPost", now)
    return now
Exemplo n.º 9
0
def get_last_post_time():
    store = KVStore.getCustomStore("tumblr")
    last_post = store.getOrElse("lastPost", 0.0)
    return last_post
Exemplo n.º 10
0
def get_tumblr_store():
    store = KVStore.getCustomStore("tumblr")
    return store