Just a simple library for caching reddit posts
Project description
Reddist
Just a python library to make reddit post caching easier.
Caching Options
- In Memory Caching
- Redis Caching
- Pickle Caching
Usage
Installation:
- Developement
poetry add git+https://github.com/CaffeineDuck/reddist
- Stable
poetry add reddist
Pickle Usage:
import asyncio
import random
from dataclasses import asdict
async def main():
reddit_cacher = PickleRedditCacher(
Reddit(
user_agent="dpydit",
client_id="CLIENT_ID",
client_secret="CLIENT_SECRET",
),
'cache.pickle',
cached_posts_count=100,
)
reddit_cacher.start_caching()
posts = await reddit_cacher.get_subreddit_posts("pics")
print(asdict(random.choice(posts)))
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Memory Usage:
import asyncio
import random
from dataclasses import asdict
async def main():
reddit_cacher = MemoryRedditCacher(
Reddit(
user_agent="dpydit",
client_id="CLIENT_ID",
client_secret="CLIENT_SECRET",
),
cached_posts_count=100,
)
reddit_cacher.start_caching()
posts = await reddit_cacher.get_subreddit_posts("pics")
print(asdict(random.choice(posts)))
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Redis Usage:
import asyncio
import random
from dataclasses import asdict
import aioredis
async def main():
redis = aioredis.from_url(
"redis://localhost"
)
async with redis.client() as conn:
reddit_cacher = RedisRedditCacher(
Reddit(
user_agent="dpydit",
client_id="CLIENT_ID",
client_secret="CLIENT_SECRET",
),
conn,
cached_posts_count=100
)
posts = await reddit_cacher.get_subreddit_posts("pics")
print(asdict(random.choice(posts)))
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
WIP (Expect Breaking Changes)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
reddist-0.1.2.tar.gz
(4.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file reddist-0.1.2.tar.gz.
File metadata
- Download URL: reddist-0.1.2.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.10.1 Linux/5.10.16.3-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14d836addb64b83f26e96c20f883ce5fcbd9f06b064e2bb5fbdc066d58a1114d
|
|
| MD5 |
700146687162cf883b44339d7a5dfede
|
|
| BLAKE2b-256 |
4fddd2263ee800bd7b525ac20f88d957e7758548ee14cefd1bc528b5e0e33091
|
File details
Details for the file reddist-0.1.2-py3-none-any.whl.
File metadata
- Download URL: reddist-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.10.1 Linux/5.10.16.3-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ea007dc4bd510412382c071b46416e58ae5a2e640ad90d1340301d734936bcf
|
|
| MD5 |
6ff83557232bd994a23403b3a7f778df
|
|
| BLAKE2b-256 |
69ef612cea7df5624c718d5911644fdbfaad8c298d3302d753fa2c9be4b2551f
|