Skip to main content

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
```

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

django-in-memory-models-1.0.1.tar.gz (2.3 kB view hashes)

Uploaded Source

Built Distribution

django_in_memory_models-1.0.1-py3-none-any.whl (3.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page