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