Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
岳巧源
/
my-awesome-project
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8b2c8e3a
authored
Jul 12, 2024
by
岳巧源
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add
parent
fea79eb5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
4 deletions
login.py
login.py
View file @
8b2c8e3a
import
random
import
time
import
redis
pool
=
redis
.
ConnectionPool
(
host
=
'10.8.0.6'
,
port
=
6379
)
class
Utils
:
def
save_kv_to_redis
(
self
,
key
:
str
,
value
:
dict
):
conn
=
redis
.
Redis
(
connection_pool
=
pool
)
conn
.
hset
(
name
=
key
,
mapping
=
value
)
class
User
:
def
__init__
(
self
,
name
=
"admin"
,
password
=
"admin@123"
):
def
__init__
(
self
,
name
=
"admin"
,
password
=
"admin@123"
,
ip
=
"127.0.0.1"
):
self
.
uid
=
self
.
generate_uid
()
self
.
name
=
name
self
.
password
=
password
self
.
ip
=
ip
self
.
register_time
=
int
(
time
.
time
())
def
generate_uid
(
self
)
->
str
:
timestamp
=
time
.
time
()
...
...
@@ -23,6 +34,15 @@ class User:
if
__name__
==
'__main__'
:
u
=
User
()
print
(
u
.
uid
)
print
(
len
(
u
.
uid
))
for
i
in
range
(
1000
):
u
=
User
()
util
=
Utils
()
data
=
{
"name"
:
u
.
name
,
"password"
:
u
.
password
,
"ip"
:
u
.
ip
,
"create_time"
:
u
.
register_time
}
util
.
save_kv_to_redis
(
u
.
uid
,
data
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment