mirror of
https://github.com/simon987/chan_feed.git
synced 2025-04-16 00:46:42 +00:00
Use sets instead of keys in state
This commit is contained in:
parent
604548bd58
commit
75f5d79a75
10
run.py
10
run.py
@ -8,7 +8,7 @@ from queue import Queue
|
|||||||
from threading import Thread
|
from threading import Thread
|
||||||
import redis
|
import redis
|
||||||
|
|
||||||
from hexlib.db import VolatileState
|
from hexlib.db import VolatileBooleanState
|
||||||
from hexlib.monitoring import Monitoring
|
from hexlib.monitoring import Monitoring
|
||||||
|
|
||||||
from chan.chan import CHANS
|
from chan.chan import CHANS
|
||||||
@ -28,9 +28,7 @@ REDIS_HOST = os.environ.get("CF_REDIS_HOST", "localhost")
|
|||||||
REDIS_PORT = os.environ.get("CF_REDIS_PORT", 6379)
|
REDIS_PORT = os.environ.get("CF_REDIS_PORT", 6379)
|
||||||
CHAN = os.environ.get("CF_CHAN", None)
|
CHAN = os.environ.get("CF_CHAN", None)
|
||||||
|
|
||||||
ARC_LISTS = os.environ.get("CF_ARC_LISTS", "arc,imhash").split(",")
|
ARC_LISTS = os.environ.get("CF_ARC_LISTS", "arc").split(",")
|
||||||
|
|
||||||
PUB_CHANNEL = os.environ.get("CF_PUB_CHANNEL", "chan_feed")
|
|
||||||
|
|
||||||
|
|
||||||
class ChanScanner:
|
class ChanScanner:
|
||||||
@ -84,11 +82,11 @@ def once(func):
|
|||||||
|
|
||||||
class ChanState:
|
class ChanState:
|
||||||
def __init__(self, prefix):
|
def __init__(self, prefix):
|
||||||
self._state = VolatileState(prefix, 86400 * 7, host=REDIS_HOST, port=REDIS_PORT)
|
self._state = VolatileBooleanState(prefix, host=REDIS_HOST, port=REDIS_PORT)
|
||||||
print("redis host=" + REDIS_HOST)
|
print("redis host=" + REDIS_HOST)
|
||||||
|
|
||||||
def mark_visited(self, item: int):
|
def mark_visited(self, item: int):
|
||||||
self._state["posts"][item] = 1
|
self._state["posts"][item] = True
|
||||||
|
|
||||||
def has_visited(self, item: int):
|
def has_visited(self, item: int):
|
||||||
return self._state["posts"][item] is not None
|
return self._state["posts"][item] is not None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user