UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'PZbRmR3xlePJCW8jX3+2chkfYQBerrgLbAOEhE5Lm4Q='
WHERE
key_id = '9ef58a198254d923df63332eb082abacb31b8362e8577c5e2f71123d2c487daf'
AND (
token = 'PZbRmR3xlePJCW8jX3+2chkfYQBerrgLbAOEhE5Lm4Q='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)