Skip to main content

Reddist

Just a python library to make reddit post caching easier.

Caching Options

  1. In Memory Caching
  2. Redis Caching
  3. 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)

Release files for reddist 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for reddist 0.1.2
File Size Uploaded
reddist-0.1.2.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for reddist 0.1.2
File Interpreter ABI Platform
reddist-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 11.1 kB

Release files / reddist-0.1.2.tar.gz

Download URL reddist-0.1.2.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
14d836addb64b83f26e96c20f883ce5fcbd9f06b064e2bb5fbdc066d58a1114d
BLAKE2b-256 checksum
How to use checksums
4fddd2263ee800bd7b525ac20f88d957e7758548ee14cefd1bc528b5e0e33091
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.10.1 Linux/5.10.16.3-microsoft-standard-WSL2

Release files / reddist-0.1.2-py3-none-any.whl

Download URL reddist-0.1.2-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ea007dc4bd510412382c071b46416e58ae5a2e640ad90d1340301d734936bcf
BLAKE2b-256 checksum
How to use checksums
69ef612cea7df5624c718d5911644fdbfaad8c298d3302d753fa2c9be4b2551f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.10.1 Linux/5.10.16.3-microsoft-standard-WSL2

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page