Caching column_property in sqlalchemy model via dogpile
I wonder if there is a chance to cache column_property using dogpile.
This is my code:
A.some_count = column_property(
select([func.count()])
.where(and_(B.__table__.c.a_id == A.__table__.c.id,
B.__table__.c.c_id == C.__table__.c.id))
.correlate(A.__table__, C.__table__)
.as_scalar()
.label('some_count'),
deferred=True)
Do anybody know how to do that? Any kind of caching would be good either with time stamp or invalidate.
Thank you for help.
python caching redis sqlalchemy dogpile.cache
add a comment |
I wonder if there is a chance to cache column_property using dogpile.
This is my code:
A.some_count = column_property(
select([func.count()])
.where(and_(B.__table__.c.a_id == A.__table__.c.id,
B.__table__.c.c_id == C.__table__.c.id))
.correlate(A.__table__, C.__table__)
.as_scalar()
.label('some_count'),
deferred=True)
Do anybody know how to do that? Any kind of caching would be good either with time stamp or invalidate.
Thank you for help.
python caching redis sqlalchemy dogpile.cache
Do you mean you'd like to cache the property so that subsequent fetches are avoided after expiring or for new instances ofAhaving the same identity?
– Ilja Everilä
Nov 23 '18 at 10:21
I would like to cache this property per instance of class A @IljaEverilä
– Rogalek
Nov 23 '18 at 13:43
But an instance already keeps the value around, once fetched.
– Ilja Everilä
Nov 23 '18 at 15:10
@IljaEverilä I think you don't understand me. So imagine situation that I have web application and I want cache this property in dogpile, because I don't want to query it, every time when I reload a page. For example cache it and reload every 1 hour. Is it possible?
– Rogalek
Nov 28 '18 at 13:36
add a comment |
I wonder if there is a chance to cache column_property using dogpile.
This is my code:
A.some_count = column_property(
select([func.count()])
.where(and_(B.__table__.c.a_id == A.__table__.c.id,
B.__table__.c.c_id == C.__table__.c.id))
.correlate(A.__table__, C.__table__)
.as_scalar()
.label('some_count'),
deferred=True)
Do anybody know how to do that? Any kind of caching would be good either with time stamp or invalidate.
Thank you for help.
python caching redis sqlalchemy dogpile.cache
I wonder if there is a chance to cache column_property using dogpile.
This is my code:
A.some_count = column_property(
select([func.count()])
.where(and_(B.__table__.c.a_id == A.__table__.c.id,
B.__table__.c.c_id == C.__table__.c.id))
.correlate(A.__table__, C.__table__)
.as_scalar()
.label('some_count'),
deferred=True)
Do anybody know how to do that? Any kind of caching would be good either with time stamp or invalidate.
Thank you for help.
python caching redis sqlalchemy dogpile.cache
python caching redis sqlalchemy dogpile.cache
edited Nov 23 '18 at 13:45
Rogalek
asked Nov 23 '18 at 9:41
RogalekRogalek
16
16
Do you mean you'd like to cache the property so that subsequent fetches are avoided after expiring or for new instances ofAhaving the same identity?
– Ilja Everilä
Nov 23 '18 at 10:21
I would like to cache this property per instance of class A @IljaEverilä
– Rogalek
Nov 23 '18 at 13:43
But an instance already keeps the value around, once fetched.
– Ilja Everilä
Nov 23 '18 at 15:10
@IljaEverilä I think you don't understand me. So imagine situation that I have web application and I want cache this property in dogpile, because I don't want to query it, every time when I reload a page. For example cache it and reload every 1 hour. Is it possible?
– Rogalek
Nov 28 '18 at 13:36
add a comment |
Do you mean you'd like to cache the property so that subsequent fetches are avoided after expiring or for new instances ofAhaving the same identity?
– Ilja Everilä
Nov 23 '18 at 10:21
I would like to cache this property per instance of class A @IljaEverilä
– Rogalek
Nov 23 '18 at 13:43
But an instance already keeps the value around, once fetched.
– Ilja Everilä
Nov 23 '18 at 15:10
@IljaEverilä I think you don't understand me. So imagine situation that I have web application and I want cache this property in dogpile, because I don't want to query it, every time when I reload a page. For example cache it and reload every 1 hour. Is it possible?
– Rogalek
Nov 28 '18 at 13:36
Do you mean you'd like to cache the property so that subsequent fetches are avoided after expiring or for new instances of
A having the same identity?– Ilja Everilä
Nov 23 '18 at 10:21
Do you mean you'd like to cache the property so that subsequent fetches are avoided after expiring or for new instances of
A having the same identity?– Ilja Everilä
Nov 23 '18 at 10:21
I would like to cache this property per instance of class A @IljaEverilä
– Rogalek
Nov 23 '18 at 13:43
I would like to cache this property per instance of class A @IljaEverilä
– Rogalek
Nov 23 '18 at 13:43
But an instance already keeps the value around, once fetched.
– Ilja Everilä
Nov 23 '18 at 15:10
But an instance already keeps the value around, once fetched.
– Ilja Everilä
Nov 23 '18 at 15:10
@IljaEverilä I think you don't understand me. So imagine situation that I have web application and I want cache this property in dogpile, because I don't want to query it, every time when I reload a page. For example cache it and reload every 1 hour. Is it possible?
– Rogalek
Nov 28 '18 at 13:36
@IljaEverilä I think you don't understand me. So imagine situation that I have web application and I want cache this property in dogpile, because I don't want to query it, every time when I reload a page. For example cache it and reload every 1 hour. Is it possible?
– Rogalek
Nov 28 '18 at 13:36
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444095%2fcaching-column-property-in-sqlalchemy-model-via-dogpile%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444095%2fcaching-column-property-in-sqlalchemy-model-via-dogpile%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Do you mean you'd like to cache the property so that subsequent fetches are avoided after expiring or for new instances of
Ahaving the same identity?– Ilja Everilä
Nov 23 '18 at 10:21
I would like to cache this property per instance of class A @IljaEverilä
– Rogalek
Nov 23 '18 at 13:43
But an instance already keeps the value around, once fetched.
– Ilja Everilä
Nov 23 '18 at 15:10
@IljaEverilä I think you don't understand me. So imagine situation that I have web application and I want cache this property in dogpile, because I don't want to query it, every time when I reload a page. For example cache it and reload every 1 hour. Is it possible?
– Rogalek
Nov 28 '18 at 13:36