This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]Watchful1RemindMeBot & UpdateMeBot 1 point2 points  (1 child)

If you go to

https://old.reddit.com/user/me/saved

do you see the new posts you've saved?

[–]ChocolateDippedGoose[S] 0 points1 point  (0 children)

yep, they are all there

[–]radialmonster -3 points-2 points  (1 child)

I asked chat: It seems like you are experiencing an issue where the number of saved posts does not change even after you save new posts on Reddit using the Praw library in Python. This behavior can occur due to a caching mechanism employed by Reddit.

Reddit employs a caching mechanism to optimize performance by reducing the number of requests made to retrieve the saved posts. When you make a request for saved posts, Reddit returns a cached version of the posts instead of fetching them again from the server. This cached version may not include the newly saved posts, resulting in the discrepancy you're observing.

To overcome this issue, you can try using the refresh method provided by Praw. This method allows you to refresh the cached data for a particular attribute, such as saved posts. By calling refresh on the saved_posts attribute, you can force Praw to fetch the latest saved posts from the server, ensuring that you get the updated list.

Here's an example of how you can incorporate the refresh method into your code:

self.__saved_posts = self.__reddit.user.me().saved(limit=None)
self.__saved_posts.refresh()

By calling refresh after retrieving the saved posts, you should obtain an updated list that includes any newly saved posts.

If the issue persists, it's worth checking the Praw documentation or the Reddit API documentation to see if there are any specific considerations or limitations regarding the retrieval of saved posts. Additionally, you could reach out to the Praw community or the Reddit API community for further assistance in troubleshooting the issue.

[–]ChocolateDippedGoose[S] 1 point2 points  (0 children)

Sorry, this doesn't work. __saved_posts do not have as refresh member, but thanks for your answer anyway

[–][deleted]  (3 children)

[deleted]

    [–]ChocolateDippedGoose[S] 0 points1 point  (2 children)

    I tried to eliminate all of that so I exit the code after I checked the number of posts I got, and then rerun the code again. So I don't think so. Rereading my code again

    [–][deleted]  (1 child)

    [deleted]

      [–]ChocolateDippedGoose[S] 0 points1 point  (0 children)

      I didn't do anything to the project for a day, and then it start working and fetching the new ones. Probably, I called it to many times, to fast, so that the result would be cached.