UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'PNnAZqlthoiPczCXypZlYlQvaIkmX7YuqQbMrE3N0Pw='
WHERE
key_id = 'ca6cdefcb7f607bd59f4591aa630e32995da4a3dd49ede6d7c201bafdb6a0f13'
AND (
token = 'PNnAZqlthoiPczCXypZlYlQvaIkmX7YuqQbMrE3N0Pw='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)