UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'fPkYjNQrH9mwskEYIG3VPsfX9jpaO8grwjJDHMliXjw='
WHERE
key_id = '38365518c5bd36c1dd961d94e54ce307927932d02b401074a9c1282c7ada3cef'
AND (
token = 'fPkYjNQrH9mwskEYIG3VPsfX9jpaO8grwjJDHMliXjw='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)