# Cache request on python

**URL:** <https://community.solace.com/t/cache-request-on-python/1790>\
**Category:** Solace Event Broker\
**Tags:** python, solace-pubsub-cache\
**Created:** [November 2, 2023, 7:50am UTC](https://community.solace.com/t/cache-request-on-python/1790 "2023-11-02T07:50:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris](https://avatars.discourse-cdn.com/v4/letter/c/958977/32.png) [@Chris](https://community.solace.com/u/Chris)\
**Post date:** [November 2, 2023, 7:50am UTC](https://community.solace.com/t/cache-request-on-python/1790/1 "2023-11-02T07:50:58Z")

</div>

I found that solace PubSub+ 1.6.0 support cache

> **[Feature Support in PubSub+ Messaging APIs](https://docs.solace.com/API/API-Developer-Guide/Feature-Support-PubSub-Messaging-APIs.htm)**

But I follow this

> **[Using PubSub+ Cache With the Python API](https://docs.solace.com/API/API-Developer-Guide-Python/Python-API-PubSub-Cache.htm)**

step to do cache request

I can not receive the cache message from **direct\_receiver.receive\_async(MessageHandlerExample())**  
but I can use **DirectMessageReceiver.** add\_subscription to get message(CacheStatus.LIVE).

and I also develope C# code it allowed call **SendCacheRequest** to receive cacehe message.

any one use python to call cache successlly?

Thanks

---

<div class="post-metadata">

**Author:** ![marc](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/marc/32/2191_2.png) [@marc](https://community.solace.com/u/marc)\
**Post date:** [November 2, 2023, 1:08pm UTC](https://community.solace.com/t/cache-request-on-python/1790/2 "2023-11-02T13:08:34Z")

</div>

Hi @Chris ,

We actually just added a sample in solace-samples-python to use PS+ Cache a few days ago. Can you take a look and see if this helps you out!

> <https://github.com/SolaceSamples/solace-samples-python/blob/main/howtos/how_to_request_cached_data.py>

---

<div class="post-metadata">

**Author:** ![Chris](https://avatars.discourse-cdn.com/v4/letter/c/958977/32.png) [@Chris](https://community.solace.com/u/Chris)\
**Post date:** [November 3, 2023, 1:56am UTC](https://community.solace.com/t/cache-request-on-python/1790/3 "2023-11-03T01:56:46Z")

</div>

Hi Marc,

I do try that **how\_to\_request\_cached\_data.py** but it still can’t receive cache data.

what detail settings should I check out?

my python code flow is  
1.MessagingService.connect()  
2.message\_receiver = MessagingService.create\_direct\_message\_receiver\_builder().build()

3.message\_receiver.start()

4.message\_receiver.receive\_async(MyMessageHandler())  
call cache request  
5.HowToUseCachedMessageSubscriptionRequests().create\_subscription\_request\_to\_receive\_latest\_message(message\_receiver , “subexpress”, “cache name”, 3000)  
or create\_subscription\_request\_to\_receive\_cached\_and\_live\_messages,

or create\_cached\_subscription\_with\_more\_options,

or create\_subscription\_to\_receiver\_only\_cached\_messages,

6.do another message\_receiver.add\_subscription  
is it correct?

---

<div class="post-metadata">

**Author:** ![marc](https://yyz1.discourse-cdn.com/solace/user_avatar/community.solace.com/marc/32/2191_2.png) [@marc](https://community.solace.com/u/marc)\
**Post date:** [November 3, 2023, 3:30pm UTC](https://community.solace.com/t/cache-request-on-python/1790/4 "2023-11-03T15:30:41Z")

</div>

Conversation is continuing here:

> **[Cache request on python](https://community.solace.com/discussion/3301/cache-request-on-python#latest)**
>
> I found that solace PubSub+ 1.6.0 support cache
