(self, key, value, state)
| 126 | ) |
| 127 | |
| 128 | def _set_with_state(self, key, value, state): |
| 129 | body = { |
| 130 | 'result': value, |
| 131 | '@timestamp': '{}Z'.format( |
| 132 | datetime.now(timezone.utc).isoformat()[:-9] |
| 133 | ), |
| 134 | } |
| 135 | try: |
| 136 | self._index( |
| 137 | id=key, |
| 138 | body=body, |
| 139 | ) |
| 140 | except elasticsearch.exceptions.ConflictError: |
| 141 | # document already exists, update it |
| 142 | self._update(key, body, state) |
| 143 | |
| 144 | def set(self, key, value): |
| 145 | return self._set_with_state(key, value, None) |