zhaoyongjie commented on pull request #17882:
URL: https://github.com/apache/superset/pull/17882#issuecomment-1011054335


   > > > > I can create the same cache of form_data and not any limitation. Is 
it by design?
   > > > 
   > > > 
   > > > @zhaoyongjie Yes. It's by design. This is especially useful when a 
user shares a URL with someone. We save the same content over a different key 
so that any modification made by a user does not affect the other one.
   > > 
   > > 
   > > The problem is that the same user session and the same query payload. It 
will generate the different cache keys. In the other word, **EVERY** HTTP 
request will generate a new **record** or **entity** in cache system. It will 
quickly consume the cache system.
   > 
   > That's not how it will work. A new key will be generated only when 
mounting. After that, we'll use the `PUT` method to replace the values.
   
   Let's try an experiment.
   
   1. add some logging info at here
   ```
   (superset) yongjie.zhao@:incubator-superset$ git diff
   diff --git a/superset/charts/form_data/commands/create.py 
b/superset/charts/form_data/commands/create.py
   index d7c2ad413..e85754751 100644
   --- a/superset/charts/form_data/commands/create.py
   +++ b/superset/charts/form_data/commands/create.py
   @@ -20,6 +20,9 @@ from superset.key_value.commands.create import 
CreateKeyValueCommand
    from superset.key_value.commands.entry import Entry
    from superset.key_value.commands.parameters import CommandParameters
    from superset.key_value.utils import cache_key
   +import logging
   +
   +logger = logging.getLogger(__name__)
   
   
    class CreateFormDataCommand(CreateKeyValueCommand):
   @@ -31,5 +34,6 @@ class CreateFormDataCommand(CreateKeyValueCommand):
            value = cmd_params.value
            if value:
                entry: Entry = {"owner": actor.get_user_id(), "value": value}
   +            logger.info(key)
                return cache_manager.chart_form_data_cache.set(key, entry)
            return False
   ```
   
   2. run flask app in terminal
   ```
   flask run
   ```
   
   3. we can get different cache key with `curl`
   ```
   curl -X POST -H 'Content-Type: application/json' -H 
'Cookie:session=.eJwlzj0KwzAMQOG7eM5gxfqxcpmgyBIthBaSdiq9ewMd3_Dg-5Q1jzhvZXkd75jKeh9lKZRaKwzrTZqwNFLpCICpjW2g9IrKie45gKNal7FF54qREaFkXa02bbCpOdRtI2XEWYnAwYnSAVWDgdhchVoky4x4XeKdokxlf7rtcVnicdX7jONPg_L9AbBAMcM.Yd6iAg.35yP0O9awEl-V1eDXaxxsZdYrw0'
 http://localhost:5000/api/v1/chart/133/form_data -d '{"value":"value"}'
   ```
   
   
   4. application log output
   ```
   
   
   Loaded your LOCAL configuration at 
[/Users/yongjie.zhao/workspace/warehouse/superset/incubator-superset/venv/superset_config.py]
   2022-01-12 
21:36:42,205:INFO:74543:superset.utils.logging_configurator:logging was 
configured successfully
   2022-01-12 21:36:42,212:INFO:74543:root:Configured event logger of type 
<class 'superset.utils.log.DBEventLogger'>
   2022-01-12 
21:36:42,215:DEBUG:74543:flask_caching.backends.filesystemcache:set key 
'__wz_cache_count'
   2022-01-12 
21:36:42,216:DEBUG:74543:flask_caching.backends.filesystemcache:set key 
'__wz_cache_count'
   
   
   2022-01-12 
21:36:47,124:INFO:74543:superset.charts.form_data.commands.create:133;o-618Isk7ggwmaWPSTuxO9Df43ZLxRjX9DWzcOeDITDH1AWR-UDXjpX2tAMbZ-vn
   2022-01-12 
21:36:47,124:DEBUG:74543:flask_caching.backends.filesystemcache:set key 
'133;o-618Isk7ggwmaWPSTuxO9Df43ZLxRjX9DWzcOeDITDH1AWR-UDXjpX2tAMbZ-vn'
   127.0.0.1 - - [12/Jan/2022 21:36:47] "POST /api/v1/chart/133/form_data 
HTTP/1.1" 201 -
   2022-01-12 21:36:47,135:INFO:74543:werkzeug:127.0.0.1 - - [12/Jan/2022 
21:36:47] "POST /api/v1/chart/133/form_data HTTP/1.1" 201 -
   2022-01-12 
21:36:48,016:INFO:74543:superset.charts.form_data.commands.create:133;KXatVxtHP9RJn9gj0L3tmosAkDBBZORisyf88EVWJ-RVHmDpVmBrETwHN1m4cvEP
   2022-01-12 
21:36:48,017:DEBUG:74543:flask_caching.backends.filesystemcache:set key 
'133;KXatVxtHP9RJn9gj0L3tmosAkDBBZORisyf88EVWJ-RVHmDpVmBrETwHN1m4cvEP'
   127.0.0.1 - - [12/Jan/2022 21:36:48] "POST /api/v1/chart/133/form_data 
HTTP/1.1" 201 -
   2022-01-12 21:36:48,023:INFO:74543:werkzeug:127.0.0.1 - - [12/Jan/2022 
21:36:48] "POST /api/v1/chart/133/form_data HTTP/1.1" 201 -
   2022-01-12 
21:36:48,899:INFO:74543:superset.charts.form_data.commands.create:133;4EQFse5BXzop3zxlgh7kblP1fp_5GRR5gK-UT7F4ku5nywhaCJ2FAFWamz6z87ze
   2022-01-12 
21:36:48,900:DEBUG:74543:flask_caching.backends.filesystemcache:set key 
'133;4EQFse5BXzop3zxlgh7kblP1fp_5GRR5gK-UT7F4ku5nywhaCJ2FAFWamz6z87ze'
   127.0.0.1 - - [12/Jan/2022 21:36:48] "POST /api/v1/chart/133/form_data 
HTTP/1.1" 201 -
   2022-01-12 21:36:48,906:INFO:74543:werkzeug:127.0.0.1 - - [12/Jan/2022 
21:36:48] "POST /api/v1/chart/133/form_data HTTP/1.1" 201 -
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to