Re: [Django] #33604: Allow CacheMiddleware.key_prefix to be a callable.

2024-06-08 Thread Django
#33604: Allow CacheMiddleware.key_prefix to be a callable.
-+-
 Reporter:  Alexandru|Owner:  Stefan
  Mărășteanu |  Farmbauer
 Type:  New feature  |   Status:  assigned
Component:  Core (Cache system)  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  1
  Needs tests:  1|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Stefan Farmbauer):

 * owner:  Alexandru Mărășteanu => Stefan Farmbauer


Old description:

> As discussed in https://groups.google.com/g/django-
> developers/c/UbD1DkV1uPo and https://code.djangoproject.com/ticket/11269
> it would be useful to be able to specify a callable which would allow for
> more dynamic caching. In my case, I need to cache differently depending
> on whether the user is authenticated or not. Another scenario is to cache
> certain pages depending on some timestamp. Other uses cases were
> mentioned in the linked pages.
>
> There exists https://github.com/peterbe/django-fancy-cache but I was able
> to address this by extending the built-in middleware so I really don't
> see an argument for a 3rd party package.
>
> I'll try to open a PR for this.

New description:

 As discussed in https://groups.google.com/g/django-
 developers/c/UbD1DkV1uPo and https://code.djangoproject.com/ticket/11269
 it would be useful to be able to specify a callable which would allow for
 more dynamic caching. In my case, I need to cache differently depending on
 whether the user is authenticated or not. Another scenario is to cache
 certain pages depending on some timestamp. Other uses cases were mentioned
 in the linked pages.

 There exists https://github.com/peterbe/django-fancy-cache but I was able
 to address this by extending the built-in middleware so I really don't see
 an argument for a 3rd party package.

 (PR is 18254)[https://github.com/django/django/pull/18254]

--
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018ff86738ba-c004e828-303b-490f-a14d-91f7989d0031-00%40eu-central-1.amazonses.com.


Re: [Django] #33604: Allow CacheMiddleware.key_prefix to be a callable.

2024-06-08 Thread Django
#33604: Allow CacheMiddleware.key_prefix to be a callable.
-+-
 Reporter:  Alexandru|Owner:  Alexandru
  Mărășteanu |  Mărășteanu
 Type:  New feature  |   Status:  assigned
Component:  Core (Cache system)  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  1
  Needs tests:  1|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Stefan Farmbauer):

 * owner:  Stefan Farmbauer => Alexandru Mărășteanu

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018ff83957bb-ea362ef4-5165-409f-9aa3-18a9bffc9d7a-00%40eu-central-1.amazonses.com.


Re: [Django] #33604: Allow CacheMiddleware.key_prefix to be a callable.

2024-06-08 Thread Django
#33604: Allow CacheMiddleware.key_prefix to be a callable.
-+-
 Reporter:  Alexandru|Owner:  Stefan
  Mărășteanu |  Farmbauer
 Type:  New feature  |   Status:  assigned
Component:  Core (Cache system)  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  1
  Needs tests:  1|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Stefan Farmbauer):

 * owner:  Alexandru Mărășteanu => Stefan Farmbauer

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018ff83703e4-3de7a8a7-6ef8-4a60-99d5-af972b7a903d-00%40eu-central-1.amazonses.com.


Re: [Django] #33604: Allow CacheMiddleware.key_prefix to be a callable.

2023-02-14 Thread Django
#33604: Allow CacheMiddleware.key_prefix to be a callable.
-+-
 Reporter:  Alexandru|Owner:  Alexandru
  Mărășteanu |  Mărășteanu
 Type:  New feature  |   Status:  assigned
Component:  Core (Cache system)  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  1
  Needs tests:  1|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-

Comment (by noneNote):

 Replying to [comment:8 Alexandru Mărășteanu]:
 > Replying to [comment:7 Mariusz Felisiak]:
 > > Docs changes are missing. Also, many tests don't work.
 >
 > I fixed the tests and updated the docs

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018650e2f183-65c4fc07-70cf-416d-af33-f158eefe9263-00%40eu-central-1.amazonses.com.


Re: [Django] #33604: Allow CacheMiddleware.key_prefix to be a callable.

2022-04-22 Thread Django
#33604: Allow CacheMiddleware.key_prefix to be a callable.
-+-
 Reporter:  Alexandru|Owner:  Alexandru
  Mărășteanu |  Mărășteanu
 Type:  New feature  |   Status:  assigned
Component:  Core (Cache system)  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  1
  Needs tests:  1|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * needs_tests:  0 => 1


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070180507c1de7-fb7af263-01a7-4248-bd2f-2d5ef2f3c516-00%40eu-central-1.amazonses.com.


Re: [Django] #33604: Allow CacheMiddleware.key_prefix to be a callable.

2022-03-30 Thread Django
#33604: Allow CacheMiddleware.key_prefix to be a callable.
-+-
 Reporter:  Alexandru|Owner:  Alexandru
  Mărășteanu |  Mărășteanu
 Type:  New feature  |   Status:  assigned
Component:  Core (Cache system)  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Alexandru Mărășteanu):

 Replying to [comment:7 Mariusz Felisiak]:
 > Docs changes are missing. Also, many tests don't work.

 I fixed the tests and updated the docs

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107017fda2d2c48-8c3d1ab7-e6c2-4b58-adef-a176c20cf36b-00%40eu-central-1.amazonses.com.


Re: [Django] #33604: Allow CacheMiddleware.key_prefix to be a callable.

2022-03-29 Thread Django
#33604: Allow CacheMiddleware.key_prefix to be a callable.
-+-
 Reporter:  Alexandru|Owner:  Alexandru
  Mărășteanu |  Mărășteanu
 Type:  New feature  |   Status:  assigned
Component:  Core (Cache system)  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * needs_better_patch:  0 => 1
 * needs_docs:  0 => 1


Comment:

 Docs changes are missing. Also, many tests don't work.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107017fd5265a0f-e174deab-2acd-47f6-9369-cc9be3184451-00%40eu-central-1.amazonses.com.


Re: [Django] #33604: Allow CacheMiddleware.key_prefix to be a callable.

2022-03-29 Thread Django
#33604: Allow CacheMiddleware.key_prefix to be a callable.
-+-
 Reporter:  Alexandru|Owner:  Alexandru
  Mărășteanu |  Mărășteanu
 Type:  New feature  |   Status:  assigned
Component:  Core (Cache system)  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Alexandru Mărășteanu):

 * owner:  nobody => Alexandru Mărășteanu
 * status:  new => assigned
 * has_patch:  0 => 1


Comment:

 I opened at PR at https://github.com/django/django/pull/15553
 Unfortunately the tests stop running at some point due to an error which
 I've yet to figure out.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107017fd513433a-02e1dc4b-7a89-49f5-b8b4-4c47117dba76-00%40eu-central-1.amazonses.com.


Re: [Django] #33604: Allow CacheMiddleware.key_prefix to be a callable.

2022-03-28 Thread Django
#33604: Allow CacheMiddleware.key_prefix to be a callable.
--+
 Reporter:  Alexandru Mărășteanu  |Owner:  nobody
 Type:  New feature   |   Status:  new
Component:  Core (Cache system)   |  Version:  dev
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+

Comment (by Alexandru Mărășteanu):

 Replying to [comment:3 Mariusz Felisiak]:
 > Tentatively accepted.

 I started writing some tests the other evening so I'll try to open a PR
 later today.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107017fd41c2a3e-96e8b53e-d3d8-4c27-9cc7-eace8d45ffa7-00%40eu-central-1.amazonses.com.


Re: [Django] #33604: Allow CacheMiddleware.key_prefix to be a callable.

2022-03-28 Thread Django
#33604: Allow CacheMiddleware.key_prefix to be a callable.
--+
 Reporter:  Alexandru Mărășteanu  |Owner:  nobody
 Type:  New feature   |   Status:  new
Component:  Core (Cache system)   |  Version:  dev
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+
Changes (by Mariusz Felisiak):

 * cc: Tobias Kunze (added)


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107017fd418f28d-f536b408-d0d7-433a-bfcb-152718ee1de4-00%40eu-central-1.amazonses.com.


Re: [Django] #33604: Allow CacheMiddleware.key_prefix to be a callable. (was: Allow `CacheMiddleware.key_prefix` to be a callable)

2022-03-28 Thread Django
#33604: Allow CacheMiddleware.key_prefix to be a callable.
--+
 Reporter:  Alexandru Mărășteanu  |Owner:  nobody
 Type:  New feature   |   Status:  new
Component:  Core (Cache system)   |  Version:  dev
 Severity:  Normal|   Resolution:
 Keywords:| Triage Stage:  Accepted
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+
Changes (by Mariusz Felisiak):

 * stage:  Unreviewed => Accepted


Comment:

 Tentatively accepted.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107017fd41843c4-21273c1d-5245-4ed7-a356-a4104b1b8f6d-00%40eu-central-1.amazonses.com.


Re: [Django] #33604: Allow `CacheMiddleware.key_prefix` to be a callable

2022-03-28 Thread Django
#33604: Allow `CacheMiddleware.key_prefix` to be a callable
-+-
 Reporter:  Alexandru|Owner:  nobody
  Mărășteanu |
 Type:  New feature  |   Status:  new
Component:  Core (Cache system)  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Alexandru Mărășteanu):

 Replying to [comment:1 Mariusz Felisiak]:
 > Thanks for the ticket. Dynamic prefixes are not supported, however you
 can use the [https://docs.djangoproject.com/en/stable/topics/cache/#cache-
 key-transformation KEY_FUNCTION] cache setting and changed `key_prefix`
 dynamically. I'm not convinced that we really need another option here.

 The need is to cache dynamically depending on the current request, on
 request properties like the user, or the query params etc. One of my use
 cases is to cache pages for anonymous users only. Another one is to cache
 pages based on some value stored in Redis. Another thing I want to do is
 to force it to skip the cache based on a query param (appending a random
 value is not always possible). Currently I do this with a custom
 middleware which extends the builtin one and simply updates
 `self.key_prefix` at the appropriate times. It seems to me it's a small
 change with great utility.

 The `KEY_FUNCTION` would be useful here if it received the request. But
 allowing a callable `key_prefix` is a lot cheaper than changing the
 signature of `KEY_FUNCTION`.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107017fd1a978ff-c6af3e99-6c61-44f6-93ca-7972f3c088c0-00%40eu-central-1.amazonses.com.


Re: [Django] #33604: Allow `CacheMiddleware.key_prefix` to be a callable

2022-03-28 Thread Django
#33604: Allow `CacheMiddleware.key_prefix` to be a callable
-+-
 Reporter:  Alexandru|Owner:  nobody
  Mărășteanu |
 Type:  New feature  |   Status:  new
Component:  Core (Cache system)  |  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Mariusz Felisiak):

 Thanks for the ticket. Dynamic prefixes are not supported, however you can
 use the [https://docs.djangoproject.com/en/stable/topics/cache/#cache-key-
 transformation KEY_FUNCTION] cache setting and changed `key_prefix`
 dynamically. I'm not convinced that we really need another option here.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107017fd179ab7f-565c83d7-03a4-4a8b-8248-fda89ef5ea19-00%40eu-central-1.amazonses.com.


[Django] #33604: Allow `CacheMiddleware.key_prefix` to be a callable

2022-03-28 Thread Django
#33604: Allow `CacheMiddleware.key_prefix` to be a callable
+
   Reporter:  Alexandru Mărășteanu  |  Owner:  nobody
   Type:  New feature   | Status:  new
  Component:  Core (Cache system)   |Version:  dev
   Severity:  Normal|   Keywords:
   Triage Stage:  Unreviewed|  Has patch:  0
Needs documentation:  0 |Needs tests:  0
Patch needs improvement:  0 |  Easy pickings:  0
  UI/UX:  0 |
+
 As discussed in https://groups.google.com/g/django-
 developers/c/UbD1DkV1uPo and https://code.djangoproject.com/ticket/11269
 it would be useful to be able to specify a callable which would allow for
 more dynamic caching. In my case, I need to cache differently depending on
 whether the user is authenticated or not. Another scenario is to cache
 certain pages depending on some timestamp. Other uses cases were mentioned
 in the linked pages.

 There exists https://github.com/peterbe/django-fancy-cache but I was able
 to address this by extending the built-in middleware so I really don't see
 an argument for a 3rd party package.

 I'll try to open a PR for this.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107017fd1657e47-0eff897b-d2fb-430b-861b-bbaf34f2d87a-00%40eu-central-1.amazonses.com.