UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'p17zAX1SKFhT3mYL49wSoqKmR5r+Asb/VLwqqAM67I0='
WHERE
key_id = 'a02143ca37bcc96930c513f96280c9dde7910b6e16f7d7f034f5db5f5b560ec2'
AND (
token = 'p17zAX1SKFhT3mYL49wSoqKmR5r+Asb/VLwqqAM67I0='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)