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