In memory models for Django, store in memory, query with instance.attribute
Project description
### Example
```
from in_memory.ssdb.fields import IntegerField
from in_memory.ssdb.fields import Sorter
#from in_memory.redis.fields import IntegerField
#from in_memory.redis.fields import Sorter
class IMAccountStatistics(InMemoryModel):
user = InMemoryOneToOneKey(User, related_name='total_statics')
total_subscription = IntegerField()
@classmethod
def get_by_user(cls, pk):
instance = cls(user_id=pk, user_foreign_id=pk)
return instance
s = User.objects.first().total_statics
print(s)
print(s.user)
print(s.total_subscription.value)
s.total_subscription += 1
print(s.total_subscription.value)
```
Output
```
IMAccountStatistics object
oldcai
0
1
```
```
from in_memory.ssdb.fields import IntegerField
from in_memory.ssdb.fields import Sorter
#from in_memory.redis.fields import IntegerField
#from in_memory.redis.fields import Sorter
class IMAccountStatistics(InMemoryModel):
user = InMemoryOneToOneKey(User, related_name='total_statics')
total_subscription = IntegerField()
@classmethod
def get_by_user(cls, pk):
instance = cls(user_id=pk, user_foreign_id=pk)
return instance
s = User.objects.first().total_statics
print(s)
print(s.user)
print(s.total_subscription.value)
s.total_subscription += 1
print(s.total_subscription.value)
```
Output
```
IMAccountStatistics object
oldcai
0
1
```
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django-in-memory-models-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a6de66fc6878364b69910a122fef46e15c7155500b68358e089bf4625575dcf |
|
MD5 | d35e839139dc3f91727e613611639276 |
|
BLAKE2b-256 | 2afbffed74f5f486647c8e6885c22d9017375ba2096edca900101993d472bc23 |
Close
Hashes for django_in_memory_models-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15567ace26677e33e67319ca6d9dc321a9acb6c1015db76587d136a7a9b3ce27 |
|
MD5 | 15d6ecfada3106e567702ce3e07d304a |
|
BLAKE2b-256 | c1a9372295c40c2c4ff00481ac1c457c0fb0c3ac35e4419d94aa391324f7ebd9 |