UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'mBBNee3KRnS9z7pYIWD1Q7Cas0b+MyYo0yO+D+DVjI4=' 
WHERE 
  key_id = '38a8af168c540fe155d2c13651b753676167884cac7dcb5398c1c01f6cf5082d' 
  AND (
    token = 'mBBNee3KRnS9z7pYIWD1Q7Cas0b+MyYo0yO+D+DVjI4=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00034