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